Skip to content
This repository was archived by the owner on May 25, 2023. It is now read-only.

Commit 216d3c6

Browse files
committed
Pass exif data to image scaling call.
This allows the loadImage library to apply the correct orientation based on Exif data and the given orientation option.
1 parent bc071fa commit 216d3c6

File tree

1 file changed

+13
-21
lines changed

1 file changed

+13
-21
lines changed

js/jquery.fileupload-image.js

+13-21
Original file line numberDiff line numberDiff line change
@@ -215,31 +215,23 @@
215215
},
216216
thumbnail,
217217
thumbnailBlob;
218-
if (data.exif) {
219-
if (options.orientation === true) {
218+
if (data.exif && options.thumbnail) {
219+
thumbnail = data.exif.get('Thumbnail');
220+
thumbnailBlob = thumbnail && thumbnail.get('Blob');
221+
if (thumbnailBlob) {
220222
options.orientation = data.exif.get('Orientation');
223+
loadImage(thumbnailBlob, resolve, options);
224+
return dfd.promise();
221225
}
222-
if (options.thumbnail) {
223-
thumbnail = data.exif.get('Thumbnail');
224-
thumbnailBlob = thumbnail && thumbnail.get('Blob');
225-
if (thumbnailBlob) {
226-
loadImage(thumbnailBlob, resolve, options);
227-
return dfd.promise();
228-
}
229-
}
230-
// Prevent orienting browser oriented images:
231-
if (loadImage.orientation) {
232-
data.orientation = data.orientation || options.orientation;
233-
}
226+
}
227+
if (data.orientation) {
234228
// Prevent orienting the same image twice:
235-
if (data.orientation) {
236-
delete options.orientation;
237-
} else {
238-
data.orientation = options.orientation;
239-
}
229+
delete options.orientation;
230+
} else {
231+
data.orientation = options.orientation;
240232
}
241233
if (img) {
242-
resolve(loadImage.scale(img, options));
234+
resolve(loadImage.scale(img, options, data));
243235
return dfd.promise();
244236
}
245237
return data;
@@ -319,7 +311,7 @@
319311
file = data.files[data.index],
320312
// eslint-disable-next-line new-cap
321313
dfd = $.Deferred();
322-
if (data.orientation && data.exifOffsets) {
314+
if (data.orientation === true && data.exifOffsets) {
323315
// Reset Exif Orientation data:
324316
loadImage.writeExifData(data.imageHead, data, 'Orientation', 1);
325317
}

0 commit comments

Comments
 (0)