Skip to content

Commit

Permalink
Pass exif data to image scaling call.
Browse files Browse the repository at this point in the history
This allows the loadImage library to apply the correct orientation based on Exif data and the given orientation option.
  • Loading branch information
blueimp committed Jun 9, 2020
1 parent bc071fa commit 216d3c6
Showing 1 changed file with 13 additions and 21 deletions.
34 changes: 13 additions & 21 deletions js/jquery.fileupload-image.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,31 +215,23 @@
},
thumbnail,
thumbnailBlob;
if (data.exif) {
if (options.orientation === true) {
if (data.exif && options.thumbnail) {
thumbnail = data.exif.get('Thumbnail');
thumbnailBlob = thumbnail && thumbnail.get('Blob');
if (thumbnailBlob) {
options.orientation = data.exif.get('Orientation');
loadImage(thumbnailBlob, resolve, options);
return dfd.promise();
}
if (options.thumbnail) {
thumbnail = data.exif.get('Thumbnail');
thumbnailBlob = thumbnail && thumbnail.get('Blob');
if (thumbnailBlob) {
loadImage(thumbnailBlob, resolve, options);
return dfd.promise();
}
}
// Prevent orienting browser oriented images:
if (loadImage.orientation) {
data.orientation = data.orientation || options.orientation;
}
}
if (data.orientation) {
// Prevent orienting the same image twice:
if (data.orientation) {
delete options.orientation;
} else {
data.orientation = options.orientation;
}
delete options.orientation;
} else {
data.orientation = options.orientation;
}
if (img) {
resolve(loadImage.scale(img, options));
resolve(loadImage.scale(img, options, data));
return dfd.promise();
}
return data;
Expand Down Expand Up @@ -319,7 +311,7 @@
file = data.files[data.index],
// eslint-disable-next-line new-cap
dfd = $.Deferred();
if (data.orientation && data.exifOffsets) {
if (data.orientation === true && data.exifOffsets) {
// Reset Exif Orientation data:
loadImage.writeExifData(data.imageHead, data, 'Orientation', 1);
}
Expand Down

0 comments on commit 216d3c6

Please sign in to comment.