【问题标题】:ImagMagick: How to add a gradient splice to an image using one convert command?ImageMagick:如何使用一个转换命令向图像添加渐变拼接?
【发布时间】:2012-08-06 13:00:25
【问题描述】:

是否可以在图像底部添加渐变拼接?似乎渐变选项requires -size,我无法提供,因为图像的大小可能会有所不同。

可以使用 convert 和 compose,但我只想使用一个命令。像这样的东西(注意这目前是无效的):

convert -fill gradient:black-white -gravity south splice 0x20 image1.jpg image2.jpg

【问题讨论】:

    标签: imagemagick gradient splice imagemagick-convert


    【解决方案1】:
    1. 我的建议是使用-append 而不是-splice
    2. 图像大小可能会有所不同,但您可以通过运行identify -format %W image1.jpg 来识别宽度。

    因此,实现您想要的一个可能的命令是:

    convert                                                \
        input.jpg                                          \
       -size $(identify -format %W input.jpg)x20 gradient: \
       -append                                             \
        output.jpg
    

    更新:

    上述命令适用于 Linux、Unix 或 Mac OS X,但不适用于 Windows。在 Windows 上,实现相同功能的最简单方法是使用以下两个命令:

    for /f "usebackq delims= " %I in (`identify -format %W input.jpg`) do set width=%I
    convert  input.jpg  -size %width%x20  gradient:  -append  output.jpg
    

    以上是在 cmd.exe 窗口中直接执行。如果将命令放入批处理文件,则需要将%I修改为%%I

    (抱歉,我现在没有 Windows 系统来验证准确的语法...)

    更新 2: Windows bat alternative for Bash inline command

    【讨论】:

    • 在 Windows 中有没有 $(identify -format %W input.jpg)x20 的替代品?
    • @Mohsen:所以根据 \@paxdiablo 的确认,我的版本也可以工作(尽管它比要求的更明确)...
    猜你喜欢
    • 2011-09-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-22
    • 2016-06-30
    • 2023-03-06
    • 2019-07-06
    • 2014-11-24
    相关资源
    最近更新 更多