imagemagick - 潜在的 Imagemagick 线性渐变错误?
问题描述
我正在尝试在 Imagemagick 中构建一个带有渐变的矩形。当我用纯色填充运行我的脚本时,我得到了构建矩形的预期行为,但是当我使用渐变作为 -fill 时,我得到一个奇怪的渐变行为,它们似乎在形状中间重新开始它们是被卷入。任何人都可以推荐一个修复或解决这个问题吗?在下面的示例中,我仅将渐变应用于底部展开作为示例(查看黑色、黑色/白色比较)。在第一幅图像中,它按预期填充为黑色,但在第二幅图像中,渐变“行为不端”并在传播的中间重新开始,没有明显的原因。
谢谢。
带有结果的工作命令示例:
convert -size 240x702 -fill black -draw "rectangle 40,2500 280,1798" legend.png legend.png
带有结果的损坏命令示例:
convert -size 240x702 -fill gradient:'#FFFFFF'-'#000000' -draw "rectangle 40,2500 280,1798" legend.png legend.png
解决方案
抱歉,您的 ImageMagick 命令行语法在几个方面存在错误:
转换 -size 240x702 -填充渐变:'#FFFFFF'-'#000000' -draw "rectangle 40,2500 280,1798" legend.png legend.png
First, you have your input legend.png image after your draw, so there is nothing to draw on. You need to read your input right after convert. See https://imagemagick.org/Usage/basics/#syntax
Second do not put quotes about each color in the gradient. Just put it around both.
Third, your -size argument is smaller than the size of the rectangle (and in fact is not used for anything). So you are trying to draw with a larger area than the image you are drawing on.
Fourth, there is no -fill for a gradient in Magick Vector Graphics as listed at https://imagemagick.org/script/magick-vector-graphics.php
Fifth, your command has no color involved in the gradient, but you show a gradated color image. Where is the color coming from or where is the grayscale gradient being used?
我没有您输入的 legend.png 图像。但是您要做的是创建一个渐变图像,然后在正确的位置将其合成到您的图例背景上。由于我没有您的图例,因此我将使用您的输出作为图例。
convert legend.png \( -size 240x2340 gradient:'#FFFFFF-#000000' \) -geometry +40+160 -compose over -composite result.png
推荐阅读
- reactjs - 评论应用程序不会在 Heroku 中自动部署
- mysql - 更改 innodb_buffer_pool_size 后 mysql 服务器关闭
- reactjs - 函数组件每次 fetch 重新渲染 3 次
- c# - 通过消息传递服务传输实体对象,对其进行更改并将其附加回来
- javascript - 从本地存储对象中添加或删除值
- r - 着色和垃圾箱位置问题
- angular - 尝试从 back4app 对象读取值并将其设置为变量但出现错误:无法设置未定义的属性“登录名”
- django - 如何将图像添加到 Django 的 Syndication RSS-feed
- javascript - 优化 Javascript 中嵌套对象和数组的减少
- python - 从给定的 csv 文件(销售数据)中使用 python 开发一个基本的搜索引擎