Skip to content

Instantly share code, notes, and snippets.

@styopdev
Created November 14, 2017 10:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save styopdev/8340db3b765e5f60ed3f70be0ecfb4e6 to your computer and use it in GitHub Desktop.
Save styopdev/8340db3b765e5f60ed3f70be0ecfb4e6 to your computer and use it in GitHub Desktop.
Image rotation by exif orientation using loadimage library.
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