rotate image if needed with javascript -
I have a preview location to show a preview of the image before uploading, the problem occurs when you use your phone Choose an image from this if it is needed to rotate the image, how do I rotate it?
My JavaScript to show the preview:
& lt; Script type = "text / javascript" & gt; Function readURL (input) {if (input.files and input.files [0]) {var reader = new FileReader (); Reader.onload = function (e) {$ ('# blah') .attr ('src', e.target.result)}; Reader.readAsDataURL (input.files [0]); }} & Lt; / Script & gt;
and html
& lt; Img src = "picture / Your_Picture_Here.png" alt = "" title = "" class = "prod_image" id = "blah" />
I recommend you take a look at the Zithub project. Everything is there to help you with your orientation problem
document.getElementById ('file-input'). Onchange = function (e) You can see an online demo that you can see. {Var loadImage = loadImage (e.target.files [0], function (IMG) {document.getElementById ("blah"). Src = img.toDataURL ();}, {Orientation: 1}); If (! LoadingImage) {// Optional Code ...}};
Please note the option orientation: 1
to properly rotate your image.
The EXIF has 8 valid values for orientation, see the letter F for 8 different values:
1 2 3 4 5 6 7 8 000000 000000 00 00 0000000000 00 00 0000000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0000000000 0000000000 00 00 00 00 00 00 00 000000 000000
Comments
Post a Comment