Skip to content

Instantly share code, notes, and snippets.

@jaketoolson
Forked from nsulistiyawan/parse-exif.js
Created January 30, 2017 01:43
Show Gist options
  • Save jaketoolson/f70fb7e1ad47342b1c2226ad119ff6ac to your computer and use it in GitHub Desktop.
Save jaketoolson/f70fb7e1ad47342b1c2226ad119ff6ac to your computer and use it in GitHub Desktop.
//parse meta data
loadImage.parseMetaData(blobOrFile, function(data) {
//default image orientation
var orientation = 0;
//if exif data available, update orientation
if (data.exif) {
orientation = data.exif.get('Orientation');
}
var loadingImage = loadImage(
blobOrFile,
function(canvas) {
//here's the base64 data result
var base64data = canvas.toDataURL('image/jpeg');
//here's example to show it as on imae preview
var img_src = base64data.replace(/^data\:image\/\w+\;base64\,/, '');
$('#result-preview').attr('src', base64data);
}, {
//should be set to canvas : true to activate auto fix orientation
canvas: true,
orientation: orientation
}
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment