-
-
Notifications
You must be signed in to change notification settings - Fork 923
Add note about providing a value to the orientation option. #65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Hey everyone, I was stumbling across the same problem. The orientation parameter understands numbers which is quite nice, but how can I pass the correct number from the exifs of the image? I tried to read the exifs first and save it to a variable, but that won't work... any tips? Thanks! }; |
|
Here's what I am doing to change the orientation: var file = evt.target.files[0];
loadImage.parseMetaData(
file,
function(data) {
var orientation = 0;
if(typeof(data.exif) !== 'undefined') {
orientation = parseInt(data.exif.get('Orientation'));
}
loadImage(
file,
function(canvas) {
var randomNumber = Math.random();
canvas.id = 'canvas-'+randomNumber;
canvas.style.display = 'none';
angular.element('body').append(canvas);
var source = document.getElementById('canvas-'+randomNumber);
console.log(source.toDataURL('image/jpeg'));
source.remove();
},
{
maxWidth: 1500,
orientation: orientation,
canvas: true
}
);
}
); |
|
Thanks for the amazingly quick answer! Helps a lot! I just found out, that it works, if loadImage is in the function, function (data) { }. Thanks! |
|
Not a problem! Hope it's extremely successful in your project. |
|
I'm trying to use the parseMetadata with a remote (URL) image, is that a problem? |
|
If you want to use function loadImageWrapper(file, callback, options) {
if (options.orientation === true) {
loadImage.parseMetaData(file, function (data) {
if (data.exif) {
options.orientation = data.exif.get('Orientation');
}
loadImage(file, callback, options);
}
}
} |
|
Commenting on this cause it's the more appropriate: |
|
Thanks for your feedback, @Grsmto. |
Just spent an hour debugging, trying to figure out why setting orientation: true in the options didn't do anything.
Turns out you have to provide an EXIF orientation value.
Making orientation: true work would be ideal, but for now a note in the documentation would be very helpful!