Status Update
Comments
ro...@google.com <ro...@google.com>
ib...@google.com <ib...@google.com> #2
ib...@google.com <ib...@google.com> #3
If the width or height is greater than 8191, left-shifting causes the sign bit to be lost, turning a '1' into a '0', which results in an incorrect width or height.
I agree there's a bug here, but I'm not sure this is quite a precise description of the problem. A quick experiment suggests that the left shift (<<
) works fine (if we are just looking at bits), but the right shift (>>
) is where the problem is introduced, because >>
does "sign extension" in Java - meaning if input value is negative (the MSB of the 32-bit int is 1
), then the result will be negative too. This can be fixed by using the unsigned right shift operator (>>>
).
You can see this in jshell
:
$ jshell
| Welcome to JShell -- Version 22
| For an introduction type: /help intro
jshell> int width = 5
width ==> 5
jshell> int height = 8192
height ==> 8192
jshell> int widthAndHeight = (width << 16) | height
widthAndHeight ==> 335872
jshell> (widthAndHeight << 18) >> 18
$8 ==> -8192
jshell> (widthAndHeight << 18) >>> 18
$9 ==> 8192
That said, I also agree that your change in
ib...@google.com <ib...@google.com>
ap...@google.com <ap...@google.com> #4
Thanks for your reply. So it it ok to be merged?
ib...@google.com <ib...@google.com>
na...@google.com <na...@google.com> #5
Branch: androidx-main
commit 59e5677498b92689c2c92801c1f371f24ca7024e
Author: Ian Baker <ibaker@google.com>
Date: Thu Aug 01 16:12:27 2024
Add a test WebP image with a height of 8192px
This exercises the bug reported in
The test is disabled for now. It can be enabled as part of merging the
fix in
This image was generated using imagemagick:
$ convert webp_without_exif.webp \
-resize 6144x8192 \
webp_without_exif_height_8192px.webp
Bug: 342697059
Test: ExifInterfaceTest
Change-Id: Ib014f54fbe8d28579f95d5d2f34e302cdd569fb9
M exifinterface/exifinterface/src/androidTest/java/androidx/exifinterface/media/ExifInterfaceTest.java
A exifinterface/exifinterface/src/androidTest/res/raw/webp_without_exif_height_8192px.webp
Description
Version used: 1.3.6
Devices/Android versions reproduced on: Issue consistently reproduced across various devices, on Android versions 9 to 13.
When reporting bugs, please always include:
1. Reproduction steps:
- Import and use the ExifInterface library version 1.3.6 in an Android project.
- Utilize the `setAttribute` method of the ExifInterface, specifying `ExifInterface.TAG_XMP` and the corresponding XMP data.
- Observe that the generated image contains duplicated XMP data.
2. How reproducible the issue is on the affected device: The issue occurs consistently on every attempt across various devices and Android versions (9 to 13).
3. If known, how reproducible the issue is on other devices and OS versions: Consistently reproducible on all tested devices and OS versions.
Where possible, please also provide:
1. A project code that reproduces the issue:
2. A screen record or screenshots showing the issue: A screenshot showing the duplicated XMP data in the binary data of the photo is attached for reference.
Additional Notes:
Upon inspection of the `setAttribute` source code in the ExifInterface library, it was found that `EXIF_TAGS` includes `IFD_TIFF_TAGS` twice. This redundancy potentially causes the XMP data to be generated twice in the resulting image, indicating a possible bug in the library's handling of XMP data.