Author Topic: Making a BASH script "PNG-friendly"  (Read 1804 times)

silversleevesx

  • Jr. Member
  • **
  • Posts: 29
Making a BASH script "PNG-friendly"
« on: March 23, 2014, 06:18:42 PM »
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

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14162
    • ExifTool Home Page
Re: Making a BASH script "PNG-friendly"
« Reply #1 on: March 25, 2014, 07:46:33 AM »
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, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

silversleevesx

  • Jr. Member
  • **
  • Posts: 29
Re: Making a BASH script "PNG-friendly"
« Reply #2 on: March 27, 2014, 04:56:56 PM »
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.)
« Last Edit: March 27, 2014, 10:56:36 PM by silversleevesx »

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14162
    • ExifTool Home Page
Re: Making a BASH script "PNG-friendly"
« Reply #3 on: March 28, 2014, 07:40:27 AM »
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, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).