Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"-*=" conflicting with "PNG-pHYs" tags #246

Open
MasterInQuestion opened this issue Mar 8, 2024 · 7 comments
Open

"-*=" conflicting with "PNG-pHYs" tags #246

MasterInQuestion opened this issue Mar 8, 2024 · 7 comments

Comments

@MasterInQuestion
Copy link

    Using "-*=" with "-PixelsPerUnit?=5906" alike doesn't work as intended:
    "PNG-pHYs" tags written then removed. (per "-v5")

    Meanwhile "-*=" with "-XResolution=300" alike on JPEG works.

@StarGeekSpaceNerd
Copy link
Collaborator

What command line are you using (Powershell/CMD/Bash/Terminal/etc)? What version of exiftool? What is your exact command?

It works correctly here with ver 12.78 on Windows CMD

C:\>exiftool -ver 
12.78

C:\>exiftool -P -overwrite_original -PixelsPerUnit?=5906 Y:\!temp\test.png
    1 image files updated

C:\>exiftool -G1 -a -s -PixelsPerUnit? Y:\!temp\test.png
[PNG-pHYs]      PixelsPerUnitX                  : 5906
[PNG-pHYs]      PixelsPerUnitY                  : 5906

@MasterInQuestion
Copy link
Author

    ExifTool 12.78.
    Commands are specifically adjusted to work across Unix Shell, Windows CMD, PowerShell.
[[

	exiftool -v5 "-*=" "-PixelsPerUnit?=5906" -overwrite_original "!.png"
	exiftool -U -ee3 -g3:5:2 -api "RequestAll=0" -api "LargeFileSupport" "!.png"

]]

@StarGeekSpaceNerd
Copy link
Collaborator

Ah, I assumed you were using the asterisk as a placeholder. I don't think I've ever seen that construct used before. Using -All= is the common approach, though this also suffers from the problem you describe.

I tried the command with some older versions back to 11.12 and the results were the same.

Furthermore, if you write another PNG tag at the same time, the PixelsPerUnit* tags are not deleted nor updated.

C:\>exiftool -G1 -a -s -e --file:all Y:\!temp\test.png
[ExifTool]      ExifToolVersion                 : 12.78
[PNG]           ImageWidth                      : 768
[PNG]           ImageHeight                     : 1152
[PNG]           BitDepth                        : 8
[PNG]           ColorType                       : RGB
[PNG]           Compression                     : Deflate/Inflate
[PNG]           Filter                          : Adaptive
[PNG]           Interlace                       : Noninterlaced
[PNG-pHYs]      PixelsPerUnitX                  : 5909
[PNG-pHYs]      PixelsPerUnitY                  : 5909
[PNG-pHYs]      PixelUnits                      : meters

C:\>exiftool -P -overwrite_original -all= -PixelsPerUnit?=100 -Description=Description Y:\!temp\test.png
    1 image files updated

C:\>exiftool -G1 -a -s -e --file:all Y:\!temp\test.png
[ExifTool]      ExifToolVersion                 : 12.78
[PNG]           ImageWidth                      : 768
[PNG]           ImageHeight                     : 1152
[PNG]           BitDepth                        : 8
[PNG]           ColorType                       : RGB
[PNG]           Compression                     : Deflate/Inflate
[PNG]           Filter                          : Adaptive
[PNG]           Interlace                       : Noninterlaced
[PNG]           Description                     : Description
[PNG-pHYs]      PixelsPerUnitX                  : 5909
[PNG-pHYs]      PixelsPerUnitY                  : 5909
[PNG-pHYs]      PixelUnits                      : meters

Phil will have to look at this when he gets the chance.

@boardhead
Copy link
Contributor

You can see the reason for this if you add the -v2 option when writing:

Writing PNG-pHYs:PixelsPerUnitX if tag exists
Writing PNG-pHYs:PixelsPerUnitY if tag exists

@Stargeek: "-*=" is the same as "-all="

  • Phil

@StarGeekSpaceNerd
Copy link
Collaborator

Yeah, I thought they were the same when I saw it, I just never seen it written like that.

But I think still think there's something wrong, as per my second example. In that example, PixelsPerUnitX/PixelsPerUnitY are preset to a value of 5906. I use -all= to clear the data, -PixelsPerUnit?=100 to set new values, and add a Description. The Description is written, but PixelsPerUnitX/PixelsPerUnitY are not changed.

The -v2 (-verbose2) option shows this output (edited)

  Deleting tags in: <snip> PNG PNG-pHYs <snip>
Writing PNG-pHYs:PixelsPerUnitX if tag exists
Writing PNG-pHYs:PixelsPerUnitY if tag exists
  Writing new tags after deleting groups: <snip> PNG PNG-pHYs <snip>
Writing PNG:Description
Writing ItemList:Description if tag exists
Writing Keys:Description if tag exists
Writing UserData:Description if tag exists
<etc…snip>
======== Y:/!temp/test.png
Rewriting Y:/!temp/test.png...
  Editing tags in: <snip> PNG PNG-pHYs <snip>
  Creating tags in: PNG PNG-pHYs 
<snip>
PNG pHYs (9 bytes):
  Deleting PNG-pHYs
  Rewriting PNG-pHYs
PNG tEXt (23 bytes):
    - PNG:Description = 'Description'
    + PNG:Description = 'Description'
PNG IDAT (20 chunks, total 1289244 bytes)
PNG IEND (end of image)
    1 image files updated

Even if I explicitly set both tags to a new value, the old one remains

C:\>exiftool -P -overwrite_original -all= -PixelsPerUnitX=100 -PixelsPerUnitY=100 -Description=Description Y:\!temp\test.png
    1 image files updated

C:\>exiftool -G1 -a -s -Description -PNG-pHYs:all Y:/!temp/test.png
[PNG]           Description                     : Description
[PNG-pHYs]      PixelsPerUnitX                  : 5906
[PNG-pHYs]      PixelsPerUnitY                  : 5906
[PNG-pHYs]      PixelUnits                      : meters

@boardhead
Copy link
Contributor

I agree that something odd is happening here, but I can't reproduce your exact observations. I need to look at this in more detail.

  • Phil

@MasterInQuestion
Copy link
Author

    "Writing PNG-pHYs:PixelsPerUnitX if tag exists"
<.>    The behavior is inconsistent with similar JPEG writing.
    (see main post)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants