开发者

imagemagick: create a .png file which is just a solid rectangle

开发者 https://www.devze.com 2023-04-13 07:01 出处:网络
I want to create a .png file whi开发者_JS百科ch is just a solid color. This must be easy to do using ImageMagick but I can\'t figure out the problem:

I want to create a .png file whi开发者_JS百科ch is just a solid color.

This must be easy to do using ImageMagick but I can't figure out the problem:

C:\tmp>convert -size 8x16 -stroke black -fill black -draw "rectangle 0,0,8,16" black.png
Magick: missing an image filename `black.png' @ error/convert.c/ConvertImageComm
and/3016.


Obviously there can be more options, like borders and etc, but if you just want an image of width x height of a given hex color, it's pretty straight forward.

Here's all it takes to make an 100x100 image of a solid dark red:

convert -size 100x100 xc:#990000 whatever.png


Note that for rgb and rgba values, you need to escape the parentheses. Building on @Mike Flynn and @luk3thomas (who correctly escapes the color code):

convert -size 100x100 xc:rgb\(0,255,0\) whatever.png
convert -size 100x100 xc:rgba\(0,255,0, 0.4\) whatever.png


In Mac

convert -size 100x100 xc:"#8a2be2" blue@2x.png
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号