【问题标题】:How do I efficiently concatenate ImageMagick and convert commands to produce a no of images如何有效地连接 ImageMagick 并转换命令以生成图像数量
【发布时间】:2014-03-06 11:39:22
【问题描述】:

我有一个尺寸为 4000*4000 的大尺寸图像。我想对图像进行各种操作:

convert a.jpg -crop 6x6@ +repage +adjoin tile_6_%d.jpg
convert a.jpg -crop 9x9@ +repage +adjoin tile_9_%d.jpg
convert a.jpg -crop 3x3@ +repage +adjoin tile_3_%d.jpg

convert a.jpg -resize 120x120  thumbnail.jpg

从而创建了一批36+81+9+1 = 127

我正在尝试做类似的事情

         convert a.jpg \
      \( +clone -resize 66% -crop 6x6@ +repage +adjoin -write tile_6x6_%d.jpg +delete \) \
      \( +clone -resize 33% -crop 3x3@ +repage +adjoin -write tile_3x3_%d.jpg +delete \) \
      \( +clone -crop 9x9@ +repage +adjoin -write tile_9x9_%d.jpg +delete \) \
                -density 150 -quality 50     -resize 120x120      thumbnail.jpg

但这并不能按预期方式工作,并且会生成大约 250 个文件。这里有什么问题?连接所有这些命令的最佳方法是什么?

【问题讨论】:

    标签: performance imagemagick image-manipulation imagemagick-convert


    【解决方案1】:

    +delete 仅删除图像序列中的最后一个图像。您想要-delete 0--1,这意味着删除图像 0 到 -1,其中负索引的 -1 指的是序列中的最后一张图像。

    详细说明一下,每个-crop 命令都会创建多个图像,因此您需要确保在将它们写入磁盘后将它们从堆栈中删除。在使用这样的复杂转换命令行时,随时查看图像堆栈发生情况的好方法是插入-write info:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-09-28
      • 2016-06-30
      • 1970-01-01
      • 2012-08-25
      • 2016-04-25
      • 1970-01-01
      • 1970-01-01
      • 2018-10-10
      相关资源
      最近更新 更多