Created
July 11, 2016 14:37
-
-
Save nsulistiyawan/ae1c93a310c8db9b1abe64044a35521c to your computer and use it in GitHub Desktop.
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
//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
Thanks for the code sample!
var img_src = base64data.replace(/^data\:image\/\w+\;base64\,/, '');
doesn't do much for you.