Modifying (large) PNG files is slow in 11.58 and newer

Started by daniels, February 10, 2020, 06:04:25 AM

Previous topic - Next topic

daniels

After updating exiftool from some older version (10.50) to the latest version (11.85) I noticed that altering metadata in (large) PNG files took significantly longer than before.

For example (60MB PNG):
Downloads/Image-ExifTool-10.50 » time ./exiftool -q -GPSLatitude=N1 -GPSLongitude=E1 ../large.png                             
./exiftool -q -GPSLatitude=N1 -GPSLongitude=E1 ../large.png  0,22s user 0,06s system 99% cpu 0,286 total


Downloads/Image-ExifTool-11.85 » time ./exiftool -q -GPSLatitude=N1 -GPSLongitude=E1 ../large.png
Warning: [minor] Changed exIf chunk to eXIf - ../large.png
./exiftool -q -GPSLatitude=N1 -GPSLongitude=E1 ../large.png  6,49s user 0,12s system 97% cpu 6,791 total


I had a look at the changelog and noticed this for version 11.58:
- Validate PNG CRC values when writing or using the Validate option

To test if that's the responsible change I modified lib/Image/ExifTool/PNG.pm:1430 and removed the or $outfile to not always do the checksum check when writing (like it did before 11.58).
With that modification times are similar to those with 10.50.

Now my question: Is disabling that verification code a bad idea or can I go ahead with it?
If it's a bad idea: What other options do I have if performance is important?

Regards
Daniel

Phil Harvey

Hi Daniel,

Thanks for this post.  I can see that such a slow down could be a problem.

I have never seen a benefit of validating the PNG checksums.  I will patch ExifTool 11.87 so the -fast option will avoid validating these checksums when writing.

There isn't much more that you could do to speed up the writing.

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

Phil Harvey

ExifTool 11.87 is now available.  You can use the -fast option with this version to bypass the PNG CRC validation.

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