follmann / favicon_maker

Create favicon files in various sizes from a base image for ruby projects
MIT License
70 stars 7 forks source link

Timestamps cause git to send new files #3

Closed cpence closed 11 years ago

cpence commented 11 years ago

I'm keeping my site in version control, using middleman and middleman-favicon-maker. Unfortunately, every time favicon_maker runs, it produces new PNG files, which contain an updated timestamp. That means that every time I build the site, it uploads a new version of the PNGs, even though there's no change in the files.

You could implement the editing of PNG metadata using chunky_png: the readme here includes examples of how to edit the metadata. It'd be really great if favicon_maker would delete the 'created' and 'modified' timestamps from the PNG metadata, so that repeated invocations produced binary-identical PNG files.

follmann commented 11 years ago

Usually in my middleman projects the build directory is part of the .gitignore list, since I don't see it as part of the source, therefore this problem never occurred to me. I deploy via Capistrano and there you have two strategies that don't require you to have build included in your repository. Either you do the build remote (what I usually do) or you do it locally and just copy the build directory via the :copy strategy. Without knowing your exact requirements, is ignoring the build folder a feasible option for you?

cpence commented 11 years ago

Not possible, unfortunately -- for all the GitHub pages systems, you're obligated to put the compiled source into a git repository.

I should have time to contribute a patch after the new year for this, if you'd like. Though I note that since you're using mini_magic, I think it's as simple as:

image.define "png:include-chunk=none,trns,gama"

right before image.write. (Obviously just for the PNG images.)

follmann commented 11 years ago

Alright, I might have time to try it out and plug it in tomorrow. Cheers!

cpence commented 11 years ago

Just tried this manually -- I can confirm that executing

for i in *.png; do
  mogrify -define "png:include-chunk=none,trns,gama" $i
done

does make bit-identical files as far as git is concerned, after multiple builds. So I think the line I posted above should work!

follmann commented 11 years ago

Alright I added the exclusion of TS from the metadata, version 0.0.9 includes the fix. The middleman extension is updated appropriately.