commons-imaging icon indicating copy to clipboard operation
commons-imaging copied to clipboard

Update TiffImageMetadata.java

Open clagenna opened this issue 8 months ago • 3 comments

Due to some HEIC file converters to JPG longitude and latitude strings gets converted from UNICODE with wrong UTF-8 coding. e.g. North "N" have hex bytes hex:4e ef bf bd For that reason latitudeRef.trim().equalsIgnoreCase("n") fails. My suggestion is to use substring(0, 1) instead of trim()

Thanks for your contribution to Apache Commons! Your help is appreciated!

Before you push a pull request, review this list:

  • [ ] Read the contribution guidelines for this project.
  • [ ] Run a successful build using the default Maven goal with mvn; that's mvn on the command line by itself.
  • [ ] Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied. This may not always be possible but is a best-practice.
  • [ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • [ ] Each commit in the pull request should have a meaningful subject line and body. Note that commits might be squashed by a maintainer on merge.

clagenna avatar May 14 '25 15:05 clagenna

This doesn't look right to me and will break existing applications that have leading or trailing whitespace in that data.

Are you saying that some other app is creating bad data?

garydgregory avatar May 14 '25 16:05 garydgregory

Well, if it'so we can insert a trim() just before substring(). For the sake of completness I've used paintshop-pro to convert heic file to jpg.

Il Mer 14 Mag 2025, 18:27 Gary Gregory @.***> ha scritto:

garydgregory left a comment (apache/commons-imaging#507) https://github.com/apache/commons-imaging/pull/507#issuecomment-2880849332

This doesn't look right to me and will break existing applications that have leading or trailing whitespace in that data.

Are you saying that some other app is creating bad data?

— Reply to this email directly, view it on GitHub https://github.com/apache/commons-imaging/pull/507#issuecomment-2880849332, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAYDPUU6JGTELTDU7YJRWRL26NVHBAVCNFSM6AAAAAB5DYTRCSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDQOBQHA2DSMZTGI . You are receiving this because you authored the thread.Message ID: @.***>

clagenna avatar May 14 '25 18:05 clagenna

Hello @clagenna Let me understand:

  • you have a HEIC file
  • you use PaintShopPro to convert it to a JPG
  • you use Commons Imaging to read the JPG

Does the data start bad in the HEIC file?

Does PSP create a bad file?

Can you provide a unit test with each file that demonstrates the issue? Ideally the test should fail if the changes to 'main' aren't applied.

Ty.

garydgregory avatar May 15 '25 18:05 garydgregory