PNG writer stores creation date unconditionally?
PNG writer stores creation date unconditionally?
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
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
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: PNG writer stores creation date unconditionally?
I am not a PNG expert, but see +set date at http://www.imagemagick.org/Usage/formats/#png_write
Re: PNG writer stores creation date unconditionally?
Try `-define png:exclude-chunk=date'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.
Re: PNG writer stores creation date unconditionally?
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
https://gist.github.com/wkoszek/fa13a4dc0d1237554f62
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: PNG writer stores creation date unconditionally?
try -define png:exclude-chunk=date, if glennrp is correct, not -png:...-png:exclude-chunk=date
Re: PNG writer stores creation date unconditionally?
The log says wkoszek did that. But it was followed withfmw42 wrote:try -define png:exclude-chunk=date, if glennrp is correct, not -png:...-png:exclude-chunk=date
Code: Select all
-define png:exclude-chunks=time
multiple chunks, use
Code: Select all
-define png:exclude-chunks=date,time
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: PNG writer stores creation date unconditionally?
Glenn,
Thanks for clarifying that.
Thanks for clarifying that.
Re: PNG writer stores creation date unconditionally?
Hi guys
https://gist.github.com/wkoszek/fa13a4dc0d1237554f62
I tried all the versions of flags/switches from this block:
e.g.: I tried line 4 by itself too (with line 5 commented out). It doesn't work.
Wojciech
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"
Wojciech
Re: PNG writer stores creation date unconditionally?
Put the "$f" last (just before the output filename).
Re: PNG writer stores creation date unconditionally?
Result is the same. Seems like it doesn't work either that way. What I've run:
http://pastebin.com/eAtWmQ0S
http://pastebin.com/eAtWmQ0S
Re: PNG writer stores creation date unconditionally?
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?
Is there a workaround for this? Something I could use with ImageMagick shipped with "brew" or "apt-get" ?
Thanks for confirming,
W.
Thanks for confirming,
W.
Re: PNG writer stores creation date unconditionally?
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.
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?
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.
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?
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: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.
- 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>