ImageMagick:在图像上放置部分透明的图块
我有一个wallpaper.jpg(大小:1920x1280)和一个部分透明的tile.gif(大小:16x16)。
在网站上,我希望将图块作为 x 和 y 重复覆盖在壁纸上。
目前,这种覆盖是使用 CSS 实现的。我想保存一个请求并使用 ImageMagick 将(重复的)tile.png 与 wall.jpg 合并。无论如何,wallpaper.jpg 是通过 ImageMagick 生成的。
根据-tile选项的文档,我想出了以下命令
convert wallpaper.jpg -size 1920x1280 tile:tile.gif -compose over -composite result.jpg
:然而,结果是一个 1920x1280 jpg 充满了瓷砖,但没有壁纸闪耀。相反,瓷砖的透明部分似乎是白色的。
文档说:
如果图块图像部分透明,则需要指定“Over”“-compose”方法。
那么出了什么问题呢?
我也尝试过 -flatten 而不是 -composite...相同的结果。
编辑: 我意识到,还有另一个 -tile 选项文档。它似乎遵循重载的概念。不幸的是,我不知道如何正确使用它。
I have a wallpaper.jpg (size: 1920x1280) and a partly transparent tile.gif (size: 16x16).
On a website I want to have the tile as a x- and y-repeated overlay over the wallpaper.
Right now, this overlay is realized using CSS. I want to save one request and merge the (repeated) tile.png with the wallpaper.jpg using ImageMagick. The wallpaper.jpg is generated via ImageMagick anyway.
Following the Documentation of the -tile option, I came up with the following command:
convert wallpaper.jpg -size 1920x1280 tile:tile.gif -compose over -composite result.jpg
The result, however, is a 1920x1280 jpg filled with the tile, but no wallpaper shining through. Instead, the transparent part of the tile seem to be white.
The documentation says:
If the tile image is partially transparent then a 'Over' "-compose" method will need to be specified.
So what's wrong?
I also tried -flatten instead of -composite... same result.
edit:
I realize, there is also another -tile option documentation. It seems to follow the concept of overloading. Unfortunately, I cannot figure out how to use it correctly.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这应该可以解决问题:(
您也可以添加
-compose over
,但这应该没有任何区别)。This should do the trick:
(you can also add
-compose over
, but that should not make any difference).不确定它是否有帮助,但您是否尝试过将您的tile.gif转换为具有Alpha/透明度的24位PNG文件? - 从头开始......
我发现了一些示例,但不确定完整的命令行:
来源:http://www.imagemagick.org/Usage/compose/#tile
Not sure if it will help, but have you tried converting your tile.gif to a 24-bit PNG file with Alpha/Transparency? - Scratch that....
I found some example showing but am unsure about the full command line:
Source: http://www.imagemagick.org/Usage/compose/#tile