EXtcreate-date and EXtmodify-date in PNG-files

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
learnr

EXtcreate-date and EXtmodify-date in PNG-files

Post by learnr »

I am using the following Imagemagick script in a batch file to resize large png-images for web upload.

Code: Select all

FOR %%a in (*.png) DO "C:\Program Files\ImageMagick-6.5.3-Q8\convert.exe" %%a -resize 300x400^ +dither -colors 64  -quality 90 %%~dpna_small.png
Every now and then the source images are recreated, and the old images are overwritten with new ones with new create and modify dates. The images are overwritten even if they have not changed compared to the old images. After this the above script creates smaller file versions for web upload. The web uploader then uses MD5 binary hashes to check whether the smaller files have changed or not, and uploads the new files, if any.

The problem is that Imagemagick adds EXtcreate-date and EXtmodify-date (creation and modify date of the source file) to the end of the resized png-file, consequently the MD5 hashes of otherwise identical smaller files don't match and the uploader treats all the updated resized files as new files.

Is there a way to avoid this, i.e. to tell Imagemagick not to include information about the source file create and modify date in the resized file?
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: EXtcreate-date and EXtmodify-date in PNG-files

Post by glennrp »

These properties are added in constitute.c, ReadImage(). The following, or some variant of it, ought to work

Code: Select all

convert input.png +define date-create +define date-modify output.png
but it doesn't. The "+define key" method does not seem to work at all. Neither does

Code: Select all

convert input.png -define date-create=0 -define date-modify=0 output.png
The -strip option

Code: Select all

convert input.png -strip output.png
should also work but doesn't.
Glenn
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: EXtcreate-date and EXtmodify-date in PNG-files

Post by magick »

Try this:
  • convert logo: +set date:create logo.miff
That should remove the date:create property.
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: EXtcreate-date and EXtmodify-date in PNG-files

Post by glennrp »

+set did not work. If I start with a PNG that has dates, they get
overwritten with new ones, whether the "+set date:create" is present
or not:

Version: ImageMagick 6.5.5-5 2009-08-31 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2009 ImageMagick Studio LLC
Mon Aug 31 19:06:10 EDT 2009

rose.png:
date:create: 2009-08-13T15:43:41-04:00
date:modify: 2009-08-13T15:43:41-04:00

convert rose.png rose_nochange.miff
date:create: 2009-08-31T19:06:11-04:00
date:modify: 2009-08-31T19:06:11-04:00

convert rose.png +set date:create rose+set_create:date.miff:
date:create: 2009-08-31T19:06:13-04:00
date:modify: 2009-08-31T19:06:13-04:00

The same thing happens if I start with "rose:" instead of "rose.png".

Glenn
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: EXtcreate-date and EXtmodify-date in PNG-files

Post by magick »

The create:date property is created each time an image is read, however, it is not saved to the file if you use +set date:create. Try this:
-> convert rose.png +set date:create logo.miff
-> more logo.miff
id=ImageMagick version=1.0
class=DirectClass colors=0 matte=False
columns=70 rows=46 depth=8
colorspace=RGB
compression=Zip quality=0
resolution=72x72
page=70x46+0+0
date:modify={2009-08-31T20:59:50-04:00}
Notice how the date:modify property is not included in logo.miff. However, when you read logo.miff it is set once again.
Post Reply