Skip to content

Commit

Permalink
JPEG decoder: Reading offsets from EXIF was off by two bytes.
Browse files Browse the repository at this point in the history
For rational numbers this worked OK by chance when both the nominator and
the denominator were < 65536, because the error was cancelled by the
division. However, this doesn't work when the nominator/denominator are
larger than 65535.

Fixed the offset, and added a test with large nom/denom.

Bug: 1143645
Change-Id: Ic8e46c580437fb4585197807c89a48f43435852a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2507110
Reviewed-by: Stephen Chenney <[email protected]>
Commit-Queue: Stephen Chenney <[email protected]>
Cr-Commit-Position: refs/heads/master@{#822179}
  • Loading branch information
noamr authored and chromium-wpt-export-bot committed Oct 29, 2020
1 parent 66b111d commit 7f969eb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
await test_valid({width: 10, height: 20, preferredWidth: 20, preferredHeight: 10, resolutionX: 36, resolutionY: 144, resolutionUnit: 2})
await test_valid({width: 10, height: 20, preferredWidth: 10, preferredHeight: 40, resolutionX: 72, resolutionY: 36, resolutionUnit: 2})
await test_valid({width: 30, height: 30, preferredWidth: 90, preferredHeight: 30, resolutionX: 24, resolutionY: 72, resolutionUnit: 2})
await test_valid({width: 10, height: 20, preferredWidth: 20, preferredHeight: 40, resolutionX: [72 * 1000000, 2 * 1000000], resolutionY: [72 * 10000000, 2 * 10000000], resolutionUnit: 2})

await test_invalid({width: 10, height: 20, preferredWidth: 20, preferredHeight: 30, resolutionX: 36, resolutionY: 36, resolutionUnit: 2})
await test_invalid({width: 10, height: 20, preferredWidth: 33, preferredHeight: 40, resolutionX: 36, resolutionY: 36, resolutionUnit: 2})
Expand Down
4 changes: 2 additions & 2 deletions density-size-correction/resources/exify.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ function createImageWithMetadata({
if (orientation !== undefined)
root[piexif.ExifIFD.Orientation] = orientation
if (resolutionX !== undefined)
root[piexif.ImageIFD.XResolution] = [resolutionX, 1]
root[piexif.ImageIFD.XResolution] = Array.isArray(resolutionX) ? resolutionX : [resolutionX, 1]
if (resolutionY !== undefined)
root[piexif.ImageIFD.YResolution] = [resolutionY, 1]
root[piexif.ImageIFD.YResolution] = Array.isArray(resolutionY) ? resolutionY : [resolutionY, 1]
if (resolutionUnit !== undefined)
root[piexif.ImageIFD.ResolutionUnit] = resolutionUnit
if (preferredWidth !== undefined)
Expand Down

0 comments on commit 7f969eb

Please sign in to comment.