Forcing iTXt instead of tEXt on PNG Header Data

Started by ianstephens, August 27, 2021, 11:00:50 AM

Previous topic - Next topic

ianstephens

We have discovered we can use ExifTool to export/import metadata from our working PNG set and import them into another set of PNGs with the same filename.  We do this once post-processed after editing.  We want to retain the data as it contains custom metadata that our image editing software removes.

The custom data we want to copy over exists in the original PNG file as an iTXt entry under the name of "EXTRAcommands".  This field contains special/custom data specific to the image we are working with.

We managed to get everything working with the following:

# new PNG tags are added to the PNG::TextualData table:
    'Image::ExifTool::PNG::TextualData' => {
        # Example 12.  PNG:NewPngTag1
        EXTRAcommands => { },
        # Example 13.  PNG:NewPngTag2
        NewPngTag2 => { },
        # Example 14.  PNG:NewPngTag3
        NewPngTag3 => { },
    },


And then finally...

exiftool -config ~/exiftool.conf -all= -tagsfromfile ~/original/%f.png -all:all ~/fixed -overwrite_original

The data is correctly extracted from the originals and added to the edited files. 

However, ExifTool adds the custom metadata as tEXt chunk instead of the required iTXt chunk that our next processing software is expecting.

I ask - is there any way to force ExifTool to write at iTXt even though there may not be special characters outside of the charset used for tEXt?

We need to force the data to be written as iTXt instead of tEXt.

I know it may sound silly as essentially the data is there under "EXTRAcommands" - but the software we are using is expecting an iTXt and will fail if it's not in that exact format.

Thank you for your help in advance - and excuse any ignorance - this is all new to us  :)

Phil Harvey

This is explained in the second and third paragraphs of the PNG TexualData Tags documentation. 

Currently, ExifTool won't write as iTXt if there are no special characters and no language code, so I am assuming that this is the case for your existing tag.

I will patch ExifTool 12.31 to allow you to force the tag to be written as iTXt like this:

        EXTRAcommands => { iTXt => 1 },

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

ianstephens

Hi Phil,

Thank you for the response.

Correct, we wanted to force the use of iTXt even though no characters were outside of the defined charset for tEXt.

I know it may sound silly but the software we are importing into isn't too complex and is expecting the iTXt and fails if it's not in this type.

Thank you for that Phil!  What is the release schedule for 12.31?  Or will you be modifying the source (GitHub) so we can download the source and compile sooner?

Do you accept donations - if so - please advise on where we can do such?

Thank you for this wonderfully useful tool.

StarGeek

Quote from: ianstephens on August 28, 2021, 11:14:33 AM
Do you accept donations - if so - please advise on where we can do such?

See the Donate button on the main page.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Phil Harvey

Version 12.31 won't be released for at least a few weeks.  But here is a 12.31 pre-release for you.

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

ianstephens

Quote from: Phil Harvey on August 28, 2021, 11:34:32 AM
Version 12.31 won't be released for at least a few weeks.  But here is a 12.31 pre-release for you.

- Phil

Phil, you're amazing - it works flawlessly. 

Thank you greatly for patching that feature in so quickly - really appreciate it.

ianstephens

Quote from: StarGeek on August 28, 2021, 11:27:46 AM
Quote from: ianstephens on August 28, 2021, 11:14:33 AM
Do you accept donations - if so - please advise on where we can do such?

See the Donate button on the main page.

Thank you for that information - we've just sent across a donation via PayPal.

Phil Harvey

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