I’m writing some Rake tasks to generate a bunch of PNGs to check into version control, and ran into a problem: every time ImageMagick generated the files, they showed up as diffs in Git, even if the pixel content was identical. The files’ hashes were different each time I generated them.
I did some hunting, and found a discussion thread “create/modify-date written into file”, but its fix (adding
+set modify-date +set create-date to the command line before the output filename) didn’t work for me — if I generated the same content twice, the two files were still different.
So I looked at the output of
identify -verbose generated.png
Which spews out quite a lot of output, but in it was this:
Properties: date:create: 2014-01-12T08:01:31-06:00 date:modify: 2014-01-12T08:01:31-06:00
Maybe they just renamed the properties in a later version of ImageMagick? (The thread was from IM 6.4; I’m on 6.8.7.) So I tried adding
+set date:create +set date:modify.
And that did it: I could generate the same file twice, and the two files were binary equal.
file 'generated.png' => ['infile.png', 'Rakefile'] do sh "convert infile.png[64x64+0+0] infile.png[64x64+128+0] +append " + "+set date:create +set date:modify generated.png" end