How to concatenate icons into a single image with ImageMagick?

安稳与你 提交于 2019-12-29 11:46:09

问题


I want to use CSS sprites on a web site instead of separate image files, for a large collection of small icons that are all the same size. How can I concatenate (tile) them into one big image using ImageMagick?


回答1:


From the page you linked, 'montage' is the tool you want. It'll take a bunch of images and concatenate/tile them into a single output. Here's an example image I've made before using the tool:
(source: davr.org)




回答2:


convert works much better than montage. It arranges images vertically or horizontally and keeps png transparency.

convert *.png -append sprites.png (append vertically)
convert *.png +append sprites.png (append horizontally)



回答3:


You are looking for:

montage -background transparent -geometry +4+4 *.png sprite.gif



回答4:


I like this script for automatical sprite/css generation. "Building CSS sprites with Bash & Imagemagick"

  • article copy in Waybackmashine https://web.archive.org/web/20150529041037/http://jaymz.eu/blog/2010/05/building-css-sprites-with-bash-imagemagick

  • script copy http://blog.kupriyanov.com/2011/01/solvedbuilding-css-sprites-with-bash.html



来源:https://stackoverflow.com/questions/88711/how-to-concatenate-icons-into-a-single-image-with-imagemagick

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!