Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

imagemagick - Concatenate multiple images vertically using convert produces many outputs

I'm trying to append multiple .jpg files into a single large image file containing the result of vertically stacking the single ones. It seems to me that Imagemagick's convert has a somewhat erratic behavior when it comes to -append, i.e vertical wise, when I try to expand a list of files passed as wildcard argument like in the instruction convert -append pg*.jpg out.jpg.

This command creates one output file for every source image there is in the directory. Even then those files aren't concatenations. They are simply copies of the original ones. I would expect one single output with the stacking.

It works just fine using +append, for horizontal stacking. Also works when I type in the name of each individual file, convert -append pg-01.jpg pg-02.jpg pg-03.jpg pg-04.jpg ... output.jpg. The expansion (*) works for a small subset of files, like 7 or 8.

I tried this convert -append `for x in img/pg-*; do echo $x; done;` img/out.jpg in the terminal but I don't know why it doesn't work!

Since I'm working with a bunch of images, I looking to know if there is any alternative for GNU/Linux or why it is behaving like this.

I'll appreciate any info.

Edit: I forgot to mention that I get this error: convert-im6.q16: width or height exceeds limit `pg-01.jpg' @ error/cache.c/OpenPixelCache/3911. when the unexpected output occurs. All images have the same width/height.

question from:https://stackoverflow.com/questions/65836856/concatenate-multiple-images-vertically-using-convert-produces-many-outputs

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Commenting these lines:

  <policy domain="resource" name="width" value="16KP"/>
  <policy domain="resource" name="height" value="16KP"/>

In /etc/ImageMagick-6/policy.xml appears to have solved the issue.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...