So I have a site with a lot of gif files (smileys to be specific). To optimize load performance I decided to reduce amount of request to one, loading all gifs as one file.
The best option I found is to create a single sprites file. There's also an ImageMagic program that helps this a lot and has awesome wiki. After tinkering around a few hours here's what I found:
play
and keyframes
as heremontage *.gif sprites.png
<area href="./base/0000.gif" shape="rect" coords="0,0,89,39" alt="" />
montage
's tile x1
parameters creates an enormous wide image (for example 200 gifs with 20 partials each x 40px each = ~ 160000px x 40px) that makes browser to crash. So I need to make it multiple rows and columns which complicates my css calculation.steps
css for animation
(X2-X1/[gif.width] if Y coordinates are in a single row), but I still don't know its speed. Furthermore if partials on sprite image located on different rows it complicates creating a keyframes play
animation that I still need to create manually (or by scripting for huge amount of gif files). For example:
montage ./*.gif -geometry +0+0 -alpha On -background "rgba(0, 0, 0, 0.0)" -quality 100 out.png
= tile
parameter to have a different gif per each row.convert -layers dispose input.gif output.gif
produces some bugs. For example Summarize my issues:
Any kind of help is appreciated. Even link to an article or site that allows to create a single sprites file + css with animation would be great. Thanks for the help in advance!
Best regards,
Thanks to ImageMagick forum I finally found the answer.
convert -background none \
\( smilie_yellow.gif -coalesce +append \) \
\( smilie_green.gif -coalesce +append \) \
\( smilie_red.gif -coalesce +append \) \
-append -flatten 3_smilies.png