Search code examples
image-processingimagemagickimagemagick-convert

how do i place a 4 * 6 image on a letter page at the top


I am using imagemagick to convert files and reposition them, i have a 4 * 6 png which i need to position on a letter canvas on the top half of the page.

I have the below command which i am using, but its confusing. can anyone suggest how i can achieve what i want.

this is what i have tried, can any one guide me on this.

convert -rotate -270 -page Letter me-9370120111400937899958.png on-9370120111400937899958.pdf

I have also tried this, but the overlayed image is not moving and is stuck to the bottom

%x{convert -page Letter -rotate -270 "/var/folders/rp/rk2q4l7j4ds_w37vwvgx46tr0000gn/T/a8.png" -geometry +50+50 "/var/folders/rp/rk2q4l7j4ds_w37vwvgx46tr0000gn/T/a8.pdf"}

I have tried reading on this link http://www.imagemagick.org/script/command-line-processing.php#geometry but could not figure out.


Solution

  • Updated Answer

    It occurred to me later that you may have meant this:

    convert -page letter -gravity north \( a.jpg -background yellow -splice 0x10 \)   a.pdf
    

    Obviously change yellow to none and increase the 0x10 to 0x20 to move further down the page, and add -rotate 90 before the splice maybe.

    Original Answer

    Not sure exactly what you mean, but I think this will get you started. Let's try some options. I will make the canvas yellow so you can see it and the file you want to position on top will be red.

    So let's try some options...

    First, let's move the image across to the right by zero pixels and down from the top-left by 40 pixels - the default position (or gravity) is NorthWest so we are positioning relative to that.

    convert -size 612x792 xc:yellow a.jpg -geometry +0+40 -composite result.jpg
    

    enter image description here

    If you want the image centred, use -gravity north and position relative to that - a little closer to the edge this time maybe:

    convert -size 612x792 xc:yellow -gravity north a.jpg -geometry +0+10 -composite result.jpg
    

    enter image description here

    If you want the background rotated:

    convert -size 792x612 xc:yellow -gravity north a.jpg -geometry +0+40 -composite result.jpg
    

    enter image description here

    If you want just the overlay rotated, do that in "aside processing":

    convert -size 612x792 xc:yellow -gravity north \( a.jpg -rotate 90 \) -geometry +0+40 -composite result.jpg
    

    enter image description here

    If you want the canvas white, change yellow to white. If you want the canvas transparent, change yellow to none.