Page 1 of 1
PNG writer stores creation date unconditionally?
Posted: 2015-11-16T20:18:02-07:00
by wkoszek
Hello,
I attempted to create myself some test data as a part of my testdata GitHub repo:
https://github.com/wkoszek/testdata/blob/master/gen.rb
I see Image Magick's PNG writer behaving in an unexpected way, which doesn't match JPG writer. Issue is related to conditions in which ImageMagick will embed a timestamp in the image.
Replicated the case through this snippet:
https://gist.github.com/wkoszek/376b93a29ee4cd9c91d6
Explanation:
- made date1.png and date2.png at different times. I see MD5 differ, meaning creation date is embedded in the image.
- made date1.jpg and date2.jpg at different times. I see MD5 be the same, meaning creation date isn't embedded in the image.
- made nodate1.png and nodate2.png at different times, but with an explicit request to not put the date in the PNG. I see MD5 is still different.
I use `png:exclude-chunk=time` since that's what I found on this forum. So far I'm not having luck with it.
My target is to make my script generate the file that is identical each time it's run, regardless of time. Shouldn't such behavior be the default?
Thanks,
Wojciech Koszek
wojciech@koszek.com
Re: PNG writer stores creation date unconditionally?
Posted: 2015-11-16T20:59:30-07:00
by fmw42
Re: PNG writer stores creation date unconditionally?
Posted: 2015-11-17T08:41:13-07:00
by glennrp
wkoszek wrote:
I use `png:exclude-chunk=time` since that's what I found on this forum. So far I'm not having luck with it.
Try `-define png:exclude-chunk=date'
Re: PNG writer stores creation date unconditionally?
Posted: 2015-11-19T23:29:36-07:00
by wkoszek
It's either a bug, or I'm doing something very wrong. I tried -png:exclude-chunk=date, and +set and nothing seems to work. My updated script and the output logs:
https://gist.github.com/wkoszek/fa13a4dc0d1237554f62
Re: PNG writer stores creation date unconditionally?
Posted: 2015-11-20T01:48:24-07:00
by fmw42
-png:exclude-chunk=date
try -define png:exclude-chunk=date, if glennrp is correct, not -png:...
Re: PNG writer stores creation date unconditionally?
Posted: 2015-11-20T06:39:30-07:00
by glennrp
fmw42 wrote:-png:exclude-chunk=date
try -define png:exclude-chunk=date, if glennrp is correct, not -png:...
The log says wkoszek did that. But it was followed with
which replaced the list of chunks to be excluded (date) with a new list (time). To exclude
multiple chunks, use
Code: Select all
-define png:exclude-chunks=date,time
instead of multiple "-define png:exclude-chunks=something" options. I'll look into improving the documentation (or the behavior) of that feature.
Re: PNG writer stores creation date unconditionally?
Posted: 2015-11-20T10:55:04-07:00
by fmw42
Glenn,
Thanks for clarifying that.
Re: PNG writer stores creation date unconditionally?
Posted: 2015-11-21T15:37:06-07:00
by wkoszek
Hi guys
https://gist.github.com/wkoszek/fa13a4dc0d1237554f62
I tried all the versions of flags/switches from this block:
Code: Select all
#f="+set date:create +set date:modify"
#f="-define png:exclude-chunks=time"
#f="-define png:exclude-chunks=tIME"
#f="-define png:exclude-chunks=date,time"
f="-define png:exclude-chunks=date -define png:exclude-chunks=time"
e.g.: I tried line 4 by itself too (with line 5 commented out). It doesn't work.
Wojciech
Re: PNG writer stores creation date unconditionally?
Posted: 2015-11-22T10:38:53-07:00
by glennrp
Put the "$f" last (just before the output filename).
Re: PNG writer stores creation date unconditionally?
Posted: 2015-11-22T17:05:38-07:00
by wkoszek
Result is the same. Seems like it doesn't work either that way. What I've run:
http://pastebin.com/eAtWmQ0S
Re: PNG writer stores creation date unconditionally?
Posted: 2015-11-22T20:39:10-07:00
by glennrp
I'm testing a fix. The bug is in coders/png.c; we test for "Date:" instead of "date:".
Re: PNG writer stores creation date unconditionally?
Posted: 2015-11-29T16:28:42-07:00
by wkoszek
Is there a workaround for this? Something I could use with ImageMagick shipped with "brew" or "apt-get" ?
Thanks for confirming,
W.
Re: PNG writer stores creation date unconditionally?
Posted: 2015-11-29T17:07:55-07:00
by glennrp
I'd use the "signature" instead of MD5 to identify identical images.
identify -verbose file1.png | grep ignature
identify -verbose file2.png | grep ignature
I omit the first letter of "signature" because I can never remember whether
it is capitalized or not.
Re: PNG writer stores creation date unconditionally?
Posted: 2015-12-03T16:36:28-07:00
by wkoszek
While I don't know what identify does, I know md5/sha1 utilities do pretty much what git will when I commit a file.
I was asking about a workaround for the PNG generation, since I think brew will catch up from the upstream with slight delay.
Re: PNG writer stores creation date unconditionally?
Posted: 2015-12-13T08:14:30-07:00
by glennrp
wkoszek wrote:While I don't know what identify does, I know md5/sha1 utilities do pretty much what git will when I commit a file.
The difference is that the "signature" reported by "identify" is calculated over the pixel date, not over the file. Therefore, the presence of "Creation date" metadata doesn't change the signature. In fact, even representing the image in a different format doesn't change the signature:
- glenn.rp> convert logo: logo.gif
glenn.rp> convert logo: logo.png
glenn.rp> identify -verbose logo: logo.gif logo.png | grep ignature
signature: 5c701306a9a985a0c93c8d11a1e761d7f8637577697fc60d7189b221388f8edf
signature: 5c701306a9a985a0c93c8d11a1e761d7f8637577697fc60d7189b221388f8edf
signature: 5c701306a9a985a0c93c8d11a1e761d7f8637577697fc60d7189b221388f8edf
glenn.rp>