Problems tagging ImageMagick PNG on Mac

Started by ShipSkip, August 27, 2016, 06:52:47 PM

Previous topic - Next topic

ShipSkip

This is a follow-on to Topic 7461

I'd like to add time & place tags to some PNG files converted from original TIFF files. But when I update certain PNG files, the tags are not visible to Mac utilities. I thought this was because of the XMP-after-IDAT problem (Topic 5347). But your response in Topic 7461 means that maybe something else is going on.

Here is my sequence of manipulations.

Environment:
Mac OS X 10.10.5
ImageMagick 6.9.2-4 Q16 x86_64 2015-12-27
exiftool 10.25

Step 0. [FWIW] I cropped a large original TIFF image to 200x200 pixels. See attached 'scan01.tif'

convert scan00.tif -crop 200x200+0+0 scan01.tif

Step 1a. Convert the TIFF to PNG using ImageMagick convert:

convert scan01.tif scan01-magick.png

Step 1b. Convert the TIFF to PNG using OS X Preview program: Open 'scan01.tif' in Preview; export as PNG.

Output file: scan01-macpreview.png

Step 2a. Add tags to 'scan01-magick.png':

cp scan01-magick.png scan01-magick+exiftool.png
exiftool -xmp:ModifyDate='1995:02:06 09:09:09' -xmp:CreateDate='1995:02:06 09:09:09' -xmp:GPSLatitude=30.33 -xmp:GPSLongitude=-97.76 scan01-magick+exiftool.png


Step 2b. Add tags to 'scan01-macpreview.png':

cp scan01-macpreview.png scan01-macpreview+exiftool.png
exiftool -xmp:ModifyDate='1995:02:06 09:09:09' -xmp:CreateDate='1995:02:06 09:09:09' -xmp:GPSLatitude=30.33 -xmp:GPSLongitude=-97.76 scan01-macpreview+exiftool.png


Step 3. Open both tagged images in Preview. Open Inspector using command-I.

  • scan01-magick+exiftool.png - tagged time & place is not visible in Inspector
  • scan01-macpreview+exiftool.png - tagged time & place is visible in Inspector

Step 4. Expose tags inside the tagged files:

exiftool -a -G1 -s scan01-magick+exiftool.png > scan01-magick+exiftool.png.txt
exiftool -a -G1 -s scan01-macpreview+exiftool.png > scan01-macpreview+exiftool.png.txt


Both files show equivalent time & place tags, but at different places in the files:

[XMP-xmp]       CreateDate                      : 1995:02:06 09:09:09
[XMP-xmp]       ModifyDate                      : 1995:02:06 09:09:09
[XMP-exif]      GPSLatitude                     : 30 deg 19' 48.00" N
[XMP-exif]      GPSLongitude                    : 97 deg 45' 36.00" W


Step 5. Confirmed that none of the PNG files exhibit the XMP-after-IDAT problem:
(method taken from Topic 7461)

exiftool -api pngearlyxmp -a -warning scan01-macpreview.png
exiftool -api pngearlyxmp -a -warning scan01-magick.png
exiftool -api pngearlyxmp -a -warning scan01-macpreview+exiftool.png
exiftool -api pngearlyxmp -a -warning scan01-magick+exiftool.png


Conclusion: ImageMagick is doing something funky to PNG metadata so that Mac utilities can't see the metadata. Strongly resembles the XMP-after-IDAT problem in Topic 5347.

My specific requests/questions:

A) When I tagged the ImageMagick-created file in Step 2a, why couldn't I see the results in Preview?

B) Is there a way to successfully tag ImageMagick-created files like 'scan01-magick.png'? ("Success" = "observable in Mac utilities.")

C) Is there a way that I can predict which files will have this problem - where simple tagging isn't visible in Mac Preview?

Thanks! I can elaborate on "why" I'm pursuing this if you like.

Phil Harvey

#1
Ah, right.

ImageMagick is storing the XMP as a zTXt chunk with the signature "Raw profile type xmp" instead of the standard iTXt chunk with the signature "XML:com.adobe.xmp".  It isn't surprising that OS X ignores this.

Your confusion is due to the fact that ExifTool will happily work with either, and won't arbitrarily change one type into another.

To fix this, the XMP must be completely deleted, then recreated: (Unfortunately this can't be done in a single command.)

1. exiftool -xmp -b FILE.png > save.xmp

2. exiftool -xmp= FILE.png

3. exiftool -api pngearlyxmp "-xmp<=save.xmp" FILE.png

Painful, I know. :(

You can use the -v option to see if the XMP is stored as an iTXt or zTXt chunk.  It must be iTXt for Preview to see it.  Use -v3 if you also want to see the chunk signatures.

- Phil

P.S. Sorry for the delay in responding, I was away on vacation and haven't had a chance to look at this until now.

Great post BTW.  Your attention to detail is amazing.

Edit:  I will add a patch to Exiftool 10.26 so that this may be done in a single command:

exiftool -xmp:all= -tagsfromfile @ -xmp FILE.png

(Note that in this command the XMP group must be deleted with -xmp:all=.  Deleting the XMP as a block with -xmp= will still have the old behaviour.  I know this is confusing, but it allows flexibility if needed.)
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

ShipSkip

Thanks very much for your responses Phil - I'll look forward to version 10.26.

StarGeek

Quote from: ShipSkip on September 15, 2016, 12:32:13 PM
Thanks very much for your responses Phil - I'll look forward to version 10.26.

Look no further, it's out today. :)
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).