[SOLVED] merge 2imgs horiz.centre, vert. start 0.88"from top

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
tukusejssirs
Posts: 4
Joined: 2014-04-07T11:11:41-07:00
Authentication code: 6789

[SOLVED] merge 2imgs horiz.centre, vert. start 0.88"from top

Post by tukusejssirs »

I want to combine (compose, merge or whatever you wanna call it) 2 images of 300 dpi. Bg image is fully white of size A5. Fg images vary in size, but they all fit in A5. What I did is the following:

Code: Select all

convert bg.tif fg.tif -gravity center -composite new.tif
This cmd centred the fg image horizontally and vertically, while I’d like to centre it only horizontally, but vertically the fg image should start 0.88 inches from the top of the bg image.

Info: ImageMagick 6.7.7-10 2013-09-10 Q16 run in terminal of Ubuntu Gnome 13.04 i386
Last edited by tukusejssirs on 2014-04-07T13:12:58-07:00, edited 1 time in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: merge 2 imgs horiz. centred, vert. start 0.88" from top

Post by fmw42 »

IM does not work in inches or dpi units. It works in pixels. So you need to convert your vertical offset from inches to pixels given your 300 dpi resolution. Then

Code: Select all

convert bg.tif fg.tif -gravity north -geometry +0+Y -composite new.tif
Where Y is the pixel offset from the top of the image. -gravity north sets the image at the top center. -geometry defines the offset from top center.

Y=300/.88 = 341
tukusejssirs
Posts: 4
Joined: 2014-04-07T11:11:41-07:00
Authentication code: 6789

Re: merge 2 imgs horiz. centred, vert. start 0.88" from top

Post by tukusejssirs »

The first step I have not been yet able to accomplish from terminal, so I opened gimp,

1. created new image (ctrl+n),[/list]
2. template: A5 (300 ppi)[/list]
3. after clicking on Advanced options, fill with: White[/list]
4. click on ok (or press enter)[/list]

Then exported (ctrl+e) it to bg.tif (when asked, select No compression and export/enter). For it had about 13 MB, I decided to scantailor it (the way as other scanned images to have the same qualities).

And finally, the command:

Code: Select all

composite -gravity center -gravity north -geometry +0+264 130b.tif blnk_300.tif new.tit
I just tried to use multiple ‘-gravity’ settings and it just worked!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: [SOLVED] merge 2imgs horiz.centre, vert. start 0.88"from

Post by fmw42 »

I just tried to use multiple ‘-gravity’ settings and it just worked!
That is because the -gravity center was likely replace by the subsequent -gravity north. The rest of the command was just as I suggested for use with -gravity north
Post Reply