Created
November 14, 2017 10:23
-
-
Save styopdev/8340db3b765e5f60ed3f70be0ecfb4e6 to your computer and use it in GitHub Desktop.
Image rotation by exif orientation using loadimage library.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
loadImage.parseMetaData( | |
file, (data) => { | |
if (!data.imageHead) { | |
return; | |
} | |
const orientation = data.exif ? data.exif[0x0112] : null; | |
if (orientation) { | |
loadImage( | |
file, | |
function (img) { | |
img.toBlob((blob) => { | |
const _file = new File([blob], file.name, { type: file.type, lastModified: file.lastModified }); | |
// upload | |
}, file.type, 1.0); | |
}, | |
{ orientation: true, maxWidth: 2000 } | |
); | |
} else { | |
// upload | |
} | |
}, | |
{ | |
maxMetaDataSize: 262144, | |
disableImageHead: false | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment