Page 1 of 1

wrong background color using extent option

Posted: 2009-03-15T15:28:41-07:00
by stefano@BL
I use the following command to resize a rectangle image and put it in a squared canvas with a white background.

Code: Select all

convert image.jpg -colorspace RGB -strip -resample 72 -resize 92x92 -background white -gravity center -extent 92x92 image4.jpg
The resize works good but the additional area that is added to have the image in 92x92 is black; I would like to have it in white.
In the command I use -background white, is it not enough?
What other option does I have to use?

And the image is note centered, even if I have used -gravity center

Thank you
bye
stefano

Re: wrong background color using extent option

Posted: 2009-03-15T16:29:19-07:00
by fmw42
stefano@BL wrote:I use the following command to resize a rectangle image and put it in a squared canvas with a white background.

Code: Select all

convert image.jpg -colorspace RGB -strip -resample 72 -resize 92x92 -background white -gravity center -extent 92x92 image4.jpg
The resize works good but the additional area that is added to have the image in 92x92 is black; I would like to have it in white.
In the command I use -background white, is it not enough?
What other option does I have to use?

And the image is note centered, even if I have used -gravity center

Thank you
bye
stefano
Your command works fine for me on IM 6.5.0-0 Q16 Mac OSX Tiger. Perhaps you have an old IM version or one with a bug. What version are you using? Try upgrading.

But why are you using -strip -resample -resize, especially -resample. I don't think that is what you want. If you want to change the dpi without changing pixel resolution (which -resample does) use -density instead. You can get mostly the same from -thumbnail, which does a resize with -strip.

convert image.jpg -colorspace RGB -thumbnail 92x92 -background white -gravity center -extent 92x92 image4.jpg

see
http://www.imagemagick.org/script/comma ... #thumbnail
http://www.imagemagick.org/script/comma ... hp#density
http://www.imagemagick.org/script/comma ... p#resample

Re: wrong background color using extent option

Posted: 2009-03-16T01:14:30-07:00
by stefano@BL
Hi fmv42,
thank you for your answer.
I am using an older version, 6.2.8 on linux. I will try to update it.

I read better the documentation about -density, thank you for you suggestion.
bye
stefano