Insert an image into another

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
elmazza
Posts: 2
Joined: 2011-11-23T03:00:49-07:00
Authentication code: 8675308

Insert an image into another

Post by elmazza »

hi all,

im using imagemagick (v. 6.7.3 q16).

im very new at it.

my problem is the following: i have an image (let's say image.jpg).

what i want to do is to insert this image inside a white image in the center. i want the image.jpg to be opaque (the "white" of the other image if it's bigger than image.jpg it's going to be seen only in the outside area of image.jpg)

could you please give me some tips to solve this?

many thanks for your time ;)
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Insert an image into another

Post by Bonzo »

There are a few different ways to do this; try:

Code: Select all

convert image.jpg white.jpg -gravity center -composite -matte output.jpg
You could add the white to the image ( extent needs to be the size of your white image ):

Code: Select all

convert image.jpg -background white -gravity center -extent 800x800 output.jpg
elmazza
Posts: 2
Joined: 2011-11-23T03:00:49-07:00
Authentication code: 8675308

Re: Insert an image into another

Post by elmazza »

many thanks!!

i think, meanwhile, i found another way as well eheh:

Code: Select all

composite -gravity Center image.jpg white.jpg result.jpg
many thanks for your answer!!!!!
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Insert an image into another

Post by Bonzo »

As I said there are lots of ways to do what you wanted.
I tend to use convert as you could for example resize your image.jpg or add a border all within the same command which is not always possible with composite.
Post Reply