Page 1 of 1

Overlay multiple images onto canvas

Posted: 2015-10-26T04:40:36-07:00
by alasdairdf
Hello,

I need to make one large image from multiple smaller images. All are pbm, but then I want the output as png. Additionally the first image needs to be resized to 50%x50%.

I understand more or less how to do this using many separate commands, but efficiency and speed is an issue so I'd like to do it in only one command.

Example:
Create white B&W (1bit) canvas sized 1000x3000
Load in first PBM image, resize 50% then overlay at position +30+77
Load in second image and over at position +30+77
Load in third image and over at position +541+300
Load in fourth image and over at position +100+1580
Then set white to be transparent
Then save as B&W PNG

Can that be done in one command?

Thanks!

Re: Overlay multiple images onto canvas

Posted: 2015-10-26T05:14:07-07:00
by snibgo
What separate commands do you have? You should be able to just stick them together, something like this (untested):

Code: Select all

convert
-size 1000x3000 canvas:white
( first.ppm -resize 50% ) -geometry +30+77 -composite
second.ppm -geometry +30+77 -composite
third.ppm -geometry +541+300 -composite
-transparent white
-colorspace gray
out.png
Adjust as required for your shell's language.

A tip: if your images are mostly white, try this first with a coloured canvas, eg "canvas:pink", so you can see what is happening.

Re: Overlay multiple images onto canvas

Posted: 2015-10-26T06:13:05-07:00
by alasdairdf
Thanks!

The positioning does not appear to be correct... if the geometry from the top-left corner of the canvas to the top-left corner of the image?

Re: Overlay multiple images onto canvas

Posted: 2015-10-26T06:39:24-07:00
by snibgo
Please show your command and sample input and output images.