Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/oracle/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Imagemagick在某些像素级别重叠多个图像_Imagemagick_Imagemagick Convert_Imagemagick Montage - Fatal编程技术网

使用Imagemagick在某些像素级别重叠多个图像

使用Imagemagick在某些像素级别重叠多个图像,imagemagick,imagemagick-convert,imagemagick-montage,Imagemagick,Imagemagick Convert,Imagemagick Montage,例如,我有4张大小为1000x800的图像。我想把所有这些图像合并成一个图像。我知道有一个命令 convert +append image[1-4].jpg output.jpg 但是我想通过重叠250像素将第二个图像合并到第一个图像中 i、 例如,在我的最终图像中,image1有750个像素,image2和Image3也有,最后一个图像有1000个像素 通过使用上面的convert命令,我们将得到一个4000x800的图像大小,但这里我希望它是((750*3)+1000*1)x800。i、

例如,我有4张大小为1000x800的图像。我想把所有这些图像合并成一个图像。我知道有一个命令

convert +append image[1-4].jpg output.jpg
但是我想通过重叠250像素将第二个图像合并到第一个图像中

i、 例如,在我的最终图像中,image1有750个像素,image2和Image3也有,最后一个图像有1000个像素

通过使用上面的convert命令,我们将得到一个4000x800的图像大小,但这里我希望它是((750*3)+1000*1)x800。i、 例如,3250x800


另外,我如何通过垂直追加来实现这一点?

您没有说要如何重叠它们。如果不需要混合,那么在ImageMagick中,可以使用smush而不是append。Smush允许偏移(间隙)或重叠。前者为正值,后者为负值,以重叠后续图像-smush垂直附加,而+smush水平附加。背景色控制参数使用正值时的间距

所以试试看

convert image[1-4].jpg +smush -256x0 output.jpg

或者,如果只有这些图像具有这种语法,那么

convert image*.jpg +smush -256x0  output.jpg

您没有说要如何重叠它们。如果不需要混合,那么在ImageMagick中,可以使用smush而不是append。Smush允许偏移(间隙)或重叠。前者为正值,后者为负值,以重叠后续图像-smush垂直附加,而+smush水平附加。背景色控制参数使用正值时的间距

所以试试看

convert image[1-4].jpg +smush -256x0 output.jpg

或者,如果只有这些图像具有这种语法,那么

convert image*.jpg +smush -256x0  output.jpg
“+smush”操作符的行为类似于“+append”,但它需要一个参数。正数将附加由那么多像素分隔的图像。负数将附加具有如此多重叠的图像。您的示例命令如下所示

convert image[1-4].jpg +smush -250 output.jpg
要垂直附加图像,请使用运算符的“-smush”形式。在任何一种情况下,操作符都将根据当前的“-gravity”设置对齐图像。

“+smush”操作符的行为类似于“+append”,但它需要一个参数。正数将附加由那么多像素分隔的图像。负数将附加具有如此多重叠的图像。您的示例命令如下所示

convert image[1-4].jpg +smush -250 output.jpg

要垂直附加图像,请使用运算符的“-smush”形式。无论哪种情况,操作员都将根据当前的“重力”设置对齐图像。

我刚刚在Imagemagick 6.9.9.33 Q16 Mac OSX中测试了以下内容

注:我使用带正值的-smush进行测试,以查看间隙而不是重叠。那只是为了测试。如果您按照最后一个命令操作,如果您希望重叠图像而不是在图像之间设置间隙,则可以使用负值

创建13个名为rose0.jpg的图像。。。rose12.jpg

convert rose: -fill white -gravity center -pointsize 18 -annotate +0+0 "0" test/rose0.jpg
convert rose: -fill white -gravity center -pointsize 18 -annotate +0+0 "1" test/rose1.jpg
convert rose: -fill white -gravity center -pointsize 18 -annotate +0+0 "2" test/rose2.jpg
convert rose: -fill white -gravity center -pointsize 18 -annotate +0+0 "3" test/rose3.jpg
convert rose: -fill white -gravity center -pointsize 18 -annotate +0+0 "4" test/rose4.jpg
convert rose: -fill white -gravity center -pointsize 18 -annotate +0+0 "5" test/rose5.jpg
convert rose: -fill white -gravity center -pointsize 18 -annotate +0+0 "6" test/rose6.jpg
convert rose: -fill white -gravity center -pointsize 18 -annotate +0+0 "7" test/rose7.jpg
convert rose: -fill white -gravity center -pointsize 18 -annotate +0+0 "8" test/rose8.jpg
convert rose: -fill white -gravity center -pointsize 18 -annotate +0+0 "9" test/rose9.jpg
convert rose: -fill white -gravity center -pointsize 18 -annotate +0+0 "10" test/rose10.jpg
convert rose: -fill white -gravity center -pointsize 18 -annotate +0+0 "11" test/rose11.jpg
convert rose: -fill white -gravity center -pointsize 18 -annotate +0+0 "12" test/rose12.jpg

然后把它们弄脏。此操作失败,仅追加0-2。(我认为这个结构只限于它看到的任何数字)

如果仅使用一位数字,则此功能有效

convert test/rose[0-9].jpg -smush 10 test/rose_smush.jpg

正确的方法是使用以下结构

convert test/rose%d.jpg[0-12] -smush 10 test/rose_smush.jpg


参见

的文件名参考部分,我刚刚在Imagemagick 6.9.9.33 Q16 Mac OSX中测试了以下内容

注:我使用带正值的-smush进行测试,以查看间隙而不是重叠。那只是为了测试。如果您按照最后一个命令操作,如果您希望重叠图像而不是在图像之间设置间隙,则可以使用负值

创建13个名为rose0.jpg的图像。。。rose12.jpg

convert rose: -fill white -gravity center -pointsize 18 -annotate +0+0 "0" test/rose0.jpg
convert rose: -fill white -gravity center -pointsize 18 -annotate +0+0 "1" test/rose1.jpg
convert rose: -fill white -gravity center -pointsize 18 -annotate +0+0 "2" test/rose2.jpg
convert rose: -fill white -gravity center -pointsize 18 -annotate +0+0 "3" test/rose3.jpg
convert rose: -fill white -gravity center -pointsize 18 -annotate +0+0 "4" test/rose4.jpg
convert rose: -fill white -gravity center -pointsize 18 -annotate +0+0 "5" test/rose5.jpg
convert rose: -fill white -gravity center -pointsize 18 -annotate +0+0 "6" test/rose6.jpg
convert rose: -fill white -gravity center -pointsize 18 -annotate +0+0 "7" test/rose7.jpg
convert rose: -fill white -gravity center -pointsize 18 -annotate +0+0 "8" test/rose8.jpg
convert rose: -fill white -gravity center -pointsize 18 -annotate +0+0 "9" test/rose9.jpg
convert rose: -fill white -gravity center -pointsize 18 -annotate +0+0 "10" test/rose10.jpg
convert rose: -fill white -gravity center -pointsize 18 -annotate +0+0 "11" test/rose11.jpg
convert rose: -fill white -gravity center -pointsize 18 -annotate +0+0 "12" test/rose12.jpg

然后把它们弄脏。此操作失败,仅追加0-2。(我认为这个结构只限于它看到的任何数字)

如果仅使用一位数字,则此功能有效

convert test/rose[0-9].jpg -smush 10 test/rose_smush.jpg

正确的方法是使用以下结构

convert test/rose%d.jpg[0-12] -smush 10 test/rose_smush.jpg


请参阅

中的文件名引用部分,如果我有15个图像要合并,该怎么办。我使用了convert image[0-14].jpg+smush-256x0 output.jpg,但它没有按预期工作。我知道我可以使用image*.jpg,但是还有其他具有相同命名约定的图像您的图像的确切命名约定是什么?是否有前导零,例如image001.jpg而不是image1.jpg?您是否有太多的图像要保存在RAM中,加上输出图像也要保存在RAM中的等价物?你得到了什么样的错误?问题是如果我想将image0添加到image14,我必须按顺序添加它。i、 图像0,图像1,图像2,图像3,…图像13,图像14。但是,当我们使用image*.jpg时,它会选择它自己的顺序,如image0、image10、image11等。像这样的image14、image1、image2、image9要使用image*.jpg,您需要使用前导零,因为该结构按字母顺序而不是数字顺序列出图像。如果我有15个图像要合并,该怎么办。我使用了convert image[0-14].jpg+smush-256x0 output.jpg,但它没有按预期工作。我知道我可以使用image*.jpg,但是还有其他具有相同命名约定的图像您的图像的确切命名约定是什么?是否有前导零,例如image001.jpg而不是image1.jpg?您是否有太多的图像要保存在RAM中,加上输出图像也要保存在RAM中的等价物?你得到了什么样的错误?问题是如果我想将image0添加到image14,我必须按顺序添加它。i、 图像0,图像1,图像2,图像3,…图像13,图像14。但是,当我们使用image*.jpg时,它会选择它自己的顺序,如image0、image10、image11等。像这样的image14、image1、image2、image9要使用image*.jpg,您需要使用前导零,因为该结构按字母顺序而不是数字顺序列出图像。