Page 1 of 1

how to expand canvas area of an image in a particular direction

Posted: 2017-06-07T08:30:14-07:00
by laxmi131
Hi team,
we have a question on if we could expand canvas area of an image in a particular direction.
Here is a screencap of what I’m referring to.
https://www.screencast.com/t/ExB1T9iNFj
(the link can be opened in internet explorer)

Let us know if there is any command with the ImageMagick scripting. Most importantly is the ability to perform percentage based expansion from a particular anchor point/direction.It would be helpful if you can give a "convert" script for expanding canvas area of an image


The IMM version which we use is ImageMagick-6.6.9-Q16 and the ghost script version is gs9.05. We have a limitation and hence we cannot upgrade the IMM version.
Thanks
lakshmi

Re: how to expand canvas area of an image in a particular direction

Posted: 2017-06-07T08:42:57-07:00
by snibgo

Code: Select all

convert rose: -gravity East -extent 120%x100% e.png
This extends the image in the x-direction only, putting the image to the east (the right) side of the new image.

I don't know if this works in v6.6.9.

Re: how to expand canvas area of an image in a particular direction

Posted: 2017-06-08T03:46:03-07:00
by laxmi131
Hi ,
Thank you so much for the below code is not working
convert rose: -gravity East -extent 120%x100% e.png
unfortunately the command is not working in v6.6.9

can you please give me an command which will work in 6.6.9

thanks

Re: how to expand canvas area of an image in a particular direction

Posted: 2017-06-08T05:25:24-07:00
by snibgo
This might work:

Code: Select all

convert rose: ( +clone -scale 120%x100% -fill White -colorize 100 ) +swap -gravity East -composite out.png
That is Windows CMD syntax. For bash, escape the parentheses: \( and \).

Re: how to expand canvas area of an image in a particular direction

Posted: 2017-06-08T06:26:46-07:00
by laxmi131
Hi ,
Thank you for the reply,
both the above mentioned codes are working . I did a mistake by not replacing Rose ;)

however I would want to expand the image on all side
hence I tried the below command and it is working . All the sides has an equal expansion (top and bottom of equal size , and left and right are of equal size )

Code: Select all

convert "%1"[0] -gravity  center -extent 120%x120% "%2".
Is it possible to expand the top more than the bottom and the sides less than the top but more than the bottom.
in other words can we perform mutilple expansion in one command
.
Please let me know if the above condition can be acheived

Re: how to expand canvas area of an image in a particular direction

Posted: 2017-06-08T06:45:32-07:00
by snibgo
You can do as many operations as you want in a single command, eg:

Code: Select all

convert rose: -gravity East -extent 120%x100% -gravity North -extent 100%x130% e.png

Re: how to expand canvas area of an image in a particular direction

Posted: 2017-06-08T22:34:51-07:00
by laxmi131
Thank you so much it is working :)

Re: how to expand canvas area of an image in a particular direction

Posted: 2017-06-08T22:57:09-07:00
by fmw42
You can also use +-X+-Y added to the extent. The + sign moves it up and to the left. The - sign moves it down and to the right.

Compare:

Code: Select all

convert rose: -gravity center -extent 200%x200% tmp1.png
with

Code: Select all

convert rose: -gravity center -extent 200%x200%-10-10 tmp2.png
The X and Y are always in pixels.