Overlay multiple images onto canvas

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
alasdairdf
Posts: 53
Joined: 2012-05-15T04:56:50-07:00
Authentication code: 13

Overlay multiple images onto canvas

Post 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!
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Overlay multiple images onto canvas

Post 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.
snibgo's IM pages: im.snibgo.com
alasdairdf
Posts: 53
Joined: 2012-05-15T04:56:50-07:00
Authentication code: 13

Re: Overlay multiple images onto canvas

Post 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?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Overlay multiple images onto canvas

Post by snibgo »

Please show your command and sample input and output images.
snibgo's IM pages: im.snibgo.com
Post Reply