Making a BASH script "PNG-friendly"

Started by silversleevesx, March 23, 2014, 06:18:42 PM

Previous topic - Next topic

silversleevesx

I have a few PNGs converted from JPEGs and have been reading a bit about how to write some of the same metadata to PNG as JPEG. I tried this sort of thing when I was still mainly an Exiv2 user, and noticed that MS Expression Media (now PhaseOne Media Pro) couldn't see the tags. I recall when Expression Media was still iView Media Pro; the writers gave information in the later versions' Release Notes about adopting some of Adobe's methods for reading metadata, to make that application more "Photoshop-friendly." And I guessed Expression Media's not seeing Exiv2-added tags as proof Andreas Huggel's application used something other than PS-ready writing routines.

Scanning the forum threads on the subject, I'm now more familiar with how ExifTool is at least able to write metadata to PNGs so to make the data visible in Adobe apps or applications that look for PNG metadata in the same places in those files as Photoshop, etc (-api earlyXMP, for example).

I've attached a copy of my most recent script for writing Caption/Description, Comment, Keywords and Supplemental Categories which I use mainly for JPEGs and MIE files. I'd appreciate some suggestions on how to write a PNG-friendly (in terms of the second "paragraph" of this post) version of this script. Adding if/then conditionals to the script itself -- including some routines and leaving others out for PNG  files as opposed to non-PNGs -- would, imo, slow it down unnecessarily. What can be written to an MIE can be written to a JPEG or a PNG; in the case of the latter, what's visible in GUI applications is different.

BZT

Phil Harvey

I would suggest using only PNG and XMP tags (preferably XMP) when writing metadata to PNG files.  Most other utilities probably won't be able to read EXIF or IPTC in these files.

- Phil
...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 ($).

silversleevesx

#2
Thanks, Phil. I appreciate the suggestion. And I've been looking at threads regarding using separators to speed up the writing of tags to JPEG files as well as PNG files. Using the script I uploaded as an example, would it be possible to replace the "set" (as in "set $keywords") and the field separators in those functions with 'sep ","'? And would that work inside a 'sep ^' for all the fields, instead of a while/do/done loop?

BZT
(Don't look too hard for a "while" loop in the uploaded script. I used BASH 4's 'mapfile' command instead. Though I have two scripts that use them, the loops aren't what slow the script down; counting, calculating length -- without commas -- and invoking ExifTool in each instance does. I've rewritten this script using '-sep' without the counting and line-length calculation, and just in Cygwin, files that used to take as much as 50 seconds or more get done in less than twenty.)

Phil Harvey

Sorry, I'm not a bash script expert, and don't have time to try to understand yours.  But if you rephrase your question in ExifTool terms I would be happy to answer it.

- Phil
...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 ($).