Page 1 of 1
extent one dimension
Posted: 2009-07-24T03:46:08-07:00
by leo
Dear all,
I'd like to extent an image in only one dimension to a fixed size while the 2nd dimension should be left untouched.
Examples:
400x400 => 400x1000
300x600 => 300x1000
800x200 => 800x1000
(gravity south)
I tried a lot of things using -extent +/-(re)page, -splice and -crop but for some reasons couldn't get it working.
convert does not like -extent x1000, really uses a width of 0 pixels then, causing an error.
I often use ImageMagick and like it very much. Please provide me with an example, I'm stuck somehow.
Best,
Leander
Re: extent one dimension
Posted: 2009-07-24T10:11:32-07:00
by fmw42
extent works by telling it what dimensions you want achieve. So if you want to preserve one dimension, then you still have to say what the value is that you want to preserve. So if the image is 100x200 and you want to make it 200x200, you have to say -extent 200x200. In other words, you have to know how big the image is in the dimension you want to preserve.
You can do that by extracting the dimension from the image, first then using that for -extent. So lets say you want to double the width and keep the height and have it centered, then
newwidth=`convert image -format "%[fx:2*w]" info:`
height=`convert image -format "%h" info:`
convert image -gravity center -background black -extent ${newwidth}x${height} result
If you want to tell a command how much to add rather than the size, then you can do that on only one dimension with the -border command. So if you want to add 50 to each horizontal side, but leave the vertical the same
convert image -bordercolor black -border 50x0 result
Re: extent one dimension
Posted: 2009-07-24T12:12:33-07:00
by magick
In other words, you have to know how big the image is in the dimension you want to preserve.
We have a patch in the Subversion trunk to support geometries like x1000 which says to preserve the image width and extend the image height to 1000 pixels.
Re: extent one dimension
Posted: 2009-07-24T14:20:36-07:00
by fmw42
great! nice addition
Re: extent one dimension
Posted: 2009-07-27T02:07:34-07:00
by leo
fmw42 wrote:height=`convert image -format "%h" info:`
yes, that's how I'm doing it now, using a little shellscript to work around it. thank you!
magick wrote:
We have a patch in the Subversion trunk to support geometries like x1000 which says to preserve the image width and extend the image height to 1000 pixels.
thats great, I guess it will be avaiblable in future stable releases? thanks,
Best,
Leo
Re: extent one dimension
Posted: 2009-08-02T23:58:49-07:00
by anthony
Unfortunately that patch BROKE -splice, -chop -border, and quite a few other things, as such the patch that was put into place has now been backed out.
As such until someone can get to a adding it directly and correctly into the Extent operator itself, it will not be available.