input - Image not displayed after camera click on some of the android devices -
i using camera in website, in mobile phone browser having problems, in of phone browser after clicking camera, image not displayed, show blank image icon.
can u plz find out problem in code?
(function () { var takepicture = document.queryselector("#take-picture"), showpicture = document.queryselector("#show-picture"); if (takepicture && showpicture) { // set events takepicture.onchange = function (event) { // reference taken picture or chosen file var files = event.target.files, file; if (files && files.length > 0) { file = files[0]; try { // window.url object var url = window.url || window.webkiturl; // create objecturl var imgurl = url.createobjecturl(file); // set img src objecturl showpicture.src = imgurl; // revoke objecturl url.revokeobjecturl(imgurl); } catch (e) { try { // fallback if createobjecturl not supported var filereader = new filereader(); filereader.onload = function (event) { showpicture.src = event.target.result; }; // filereader.readasdataurl(file); filereader.readasbinarystring(file); var exif = exif.readfrombinaryfile(new binaryfile(this.result)); switch(exif.orientation){ case 8: showpicture.rotate(90*math.pi/180); break; case 3: showpicture.rotate(180*math.pi/180); break; case 6: showpicture.rotate(-90*math.pi/180); break; } } catch (e) { // display error message var error = document.queryselector("#error"); if (error) { error.innerhtml = "neither createobjecturl or filereader supported"; } } } } }; } })();
<input type="file" id="take-picture" accept="image/*"> <div id="mobilecameraoutput"> <img src="about:blank" alt="" id="show-picture" /></div>
Comments
Post a Comment