Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add an image on top of existing one with ImageMagick command line

Tags:

imagemagick

i would like to add a series of images to existing one, using imagemagick command line.

  • i have this image: http://tinypic.com/r/313386r/6 and
  • i would like to add this to this one: http://tinypic.com/r/k0jbqs/6
  • to get more or less this effect: http://tinypic.com/r/wtja74/6 .

as you see, this is not only adding an image. i found http://www.imagemagick.org/Usage/compose/ where i could see some examples, but what i need is to fill each 'block'.

i have exact position where each block starts and ends, also i have a scale parameter to scale it down.

i think i could use

composite -geometry +31+105  toadd.gif source.gif  newfile.jpg

but this is only one image added, and i need it scaled down.

i was wondering if i can create some kind of rectangles and fill them with my image.

any idea how it can be solved?

like image 967
gerpaick Avatar asked Jun 19 '12 05:06

gerpaick


1 Answers

Convert would be better as you can keep adding images with composite or layers.

Here is a very rough example and I would probably start off with a longer section of wall so you could crop it when resizing. There is still going to be quite a bit of user input to fix the locations as I pressume you do not always have the same amount of walls at the same length. I would write some code to input details into a form as it would be easier than altering the code each time.

convert k0jbqs.jpg \
   ( 313386r.png -thumbnail x25 ) -gravity west   -geometry  +0+30 -composite \
   ( 313386r.png -thumbnail x25 ) -gravity center -geometry +80+30 -composite \
   ( 313386r.png -thumbnail x25 ) -gravity east   -geometry  +0+30 -composite \
   output.png

You would need to take the line breaks out I just added those to make the code readable.

NOTES: Thumbnail resizes the brick image; you can forget the gravity and just use -geometry and the numbers are the positions from the top left corner and -composite puts the new image over the previous image.

like image 80
Bonzo Avatar answered Sep 20 '22 02:09

Bonzo