Flatten multiple layers, all centered
Posted: 2018-09-23T10:45:08-07:00
Hi everyone,
I have N layers I would like to flatten in only one image. The layers are of various size and I would like them to be all centered in the final image. And I wasn't able to to find a solution to do that using the `-layers flatten` operator.
I read in the doc (https://www.imagemagick.org/Usage/layers/#flatten , https://www.imagemagick.org/Usage/compose/#geometry) the `-layers flatten` operator does not use the `-gravity` setting. But that's ideally something equivalent I would like to achieve.
I could use the `-composite` operator instead to merge layers two by two. But the ImageMagick command will be generated by a script and using the `-layers` operator would be somewhat preferable since the filenames would be grouped together, instead of being interleaved with operators.
I have N layers I would like to flatten in only one image. The layers are of various size and I would like them to be all centered in the final image. And I wasn't able to to find a solution to do that using the `-layers flatten` operator.
Code: Select all
convert 'bkgnd.png' \
'legal.png' \
'c2a827c66a5b37625c95626f8b84d07b-parts1.png' \
# potentially many ofther files here
'-gravity' 'center' '-flatten' \
'c2a827c66a5b37625c95626f8b84d07b.png'
I could use the `-composite` operator instead to merge layers two by two. But the ImageMagick command will be generated by a script and using the `-layers` operator would be somewhat preferable since the filenames would be grouped together, instead of being interleaved with operators.