Commit d641260a authored by Noel Gordon's avatar Noel Gordon Committed by Commit Bot

[piexwasm] Swap RAW image details width and height if needed

Orientations of 5 or more flip the image width/height on render, while
our returned EXIF IFD data does not: https://crbug.com/1039141#c9

Fix that: flip the EXIF IFD metadata width/height if needed.

Tbr: lucmult
Bug: 1039141
Change-Id: Icfaece4bedc49b2ab6870a763cea21939b384c3a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2060442Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Commit-Queue: Noel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#742077}
parent fc2a7f58
......@@ -298,9 +298,9 @@ class ImageBuffer {
return {
thumbnail: new Uint8Array(view).buffer,
mimeType: 'image/jpeg',
ifd: this.details(result, preview.orientation),
orientation: preview.orientation,
colorSpace: preview.colorSpace,
ifd: this.details(result),
id: this.id,
};
}
......@@ -341,9 +341,9 @@ class ImageBuffer {
return {
thumbnail: new Uint8Array(view).buffer,
mimeType: 'image/jpeg',
ifd: this.details(result, thumbnail.orientation),
orientation: thumbnail.orientation,
colorSpace: thumbnail.colorSpace,
ifd: this.details(result),
id: this.id,
};
}
......@@ -437,9 +437,9 @@ class ImageBuffer {
return {
thumbnail: bitmap.buffer,
mimeType: 'image/bmp',
ifd: this.details(result, thumbnail.orientation),
orientation: thumbnail.orientation,
colorSpace: thumbnail.colorSpace,
ifd: this.details(result),
id: this.id,
};
}
......@@ -451,9 +451,10 @@ class ImageBuffer {
*
* @private
* @param {!PiexWasmImageResult} result
* @param {number} orientation - image EXIF orientation
* @return {?string}
*/
details(result) {
details(result, orientation) {
const details = result.details;
if (!details) {
return null;
......@@ -472,6 +473,13 @@ class ImageBuffer {
}
}
const usesWidthAsHeight = orientation >= 5;
if (usesWidthAsHeight) {
const width = format.width;
format.width = format.height;
format.height = width;
}
return JSON.stringify(format);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment