imagemagick:创建一个 .png 文件,它只是一个实心矩形

发布于 2024-12-10 02:54:20 字数 280 浏览 2 评论 0原文

我想创建一个纯色的 .png 文件。

使用 ImageMagick 一定很容易做到这一点,但我无法找出问题所在:

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.

I want to create a .png file which 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

花开半夏魅人心 2024-12-17 02:54:20

显然,可以有更多选项,例如边框等,但如果您只想要给定十六进制颜色的宽度 x 高度的图像,那么它非常简单。

以下是制作 100x100 纯深红色图像所需的全部操作:

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

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
何以心动 2024-12-17 02:54:20

请注意,对于 rgb 和 rgba 值,您需要转义括号。以@Mike Flynn 和@luk3thomas(正确转义颜色代码)为基础:

convert -size 100x100 xc:rgb\(0,255,0\) whatever.png
convert -size 100x100 xc:rgba\(0,255,0, 0.4\) 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
混吃等死 2024-12-17 02:54:20

在苹果电脑中

convert -size 100x100 xc:"#8a2be2" [email protected]

In Mac

convert -size 100x100 xc:"#8a2be2" [email protected]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文