Page 1 of 1

resizing and padding problem in Centos 5.4

Posted: 2009-10-24T15:05:50-07:00
by outdoorben
Hi --

Help, please! I have having a heck of a time getting convert to resize and pad out an image.

Centos 5.4.
ImageMagick.i386 0:6.2.8.0-4.el5_1.1

The background is staying black and the original image is not centered.

Original:
http://www.outdoorkids.com/images/swatc ... DN-BLK.jpg

Output
http://www.outdoorkids.com/images/swatc ... -BLK_1.jpg

Here is the command I used:

convert PAAAAAAAELALCFDN-BLK.jpg -resize 300X300 -background white -extent 300X300 -gravity center PAAAAAAAELALCFDN-BLK_1.jpg

Thank you,

-Ben

Re: resizing and padding problem in Centos 5.4

Posted: 2009-10-24T15:36:44-07:00
by fmw42
Your IM is too old. see http://www.imagemagick.org/Usage/crop/#extent

You need IM 6.3.2 or higher for -extent to recognize -background and -gravity. Also you should put -gravity before -extent.

As an alternate, you can create a white image of size 300x300 and composite your image over that white background using -gravity to center it.

see http://www.imagemagick.org/Usage/layers/#composite
or http://www.imagemagick.org/Usage/layers/#convert

convert \( -size 300x300 xc:white \) \( yourimage -resize 300x300 \) -gravity center -composite result

Re: resizing and padding problem in Centos 5.4

Posted: 2009-10-24T16:55:21-07:00
by outdoorben
Makes me wonder why such an old version is included in Centos...? Regardless, thank you for the great advice! I spent hours trying to solve this and was up against a brick wall.

-Ben

Re: resizing and padding problem in Centos 5.4

Posted: 2009-10-24T18:08:25-07:00
by fmw42
Do a Google search and see if you can find a more current version with Centos or compatible with Centos.

Perhaps someone else or one of the IM folks can suggest where to find a more current upgrade

Re: resizing and padding problem in Centos 5.4

Posted: 2009-10-25T01:09:13-07:00
by anthony
You can compile your own centos RPM from source.
http://www.imagemagick.org/Usage/api/#build
That makes it easier to upgrade and control the IM version that is installed.

CentOS is old not just for IM but for all packages. It's design criteria is as a stable server OS and thus uses older version that are known to work rather than bleeding edge versions that may have bugs.

Re: resizing and padding problem in Centos 5.4

Posted: 2009-10-25T10:40:54-07:00
by outdoorben
Hi --

First, I'm a semi-newbie at all of this, so my apologies if I'm in need of a clue. That being said, I tried to install from source with some help from this guide that had already worked out some dependency issues: http://andrewduck.name/2009/01/imagemag ... -centos-5/

Attempt 1:

yum remove ImageMagick
yum install tcl-devel libpng-devel libjpeg-devel ghostscript-devel bzip2-devel freetype-devel libtiff-devel
wget ftp://ftp.imagemagick.org/pub/ImageMagi ... ick.tar.gz
tar zxvf ImageMagick.tar.gz
cd ImageMagick-6.5.7-1/
./configure --prefix=/usr/local --with-bzlib=yes --with-fontconfig=yes --with-freetype=yes \
--with-gslib=yes --with-gvc=yes --with-jpeg=yes --with-jp2=yes --with-png=yes --with-tiff=yes
make clean
make
make install

After the make command, there were several warnings about dereferencing that may or may not be important. Example:

magick/distort.c:2399: warning: dereferencing type-punned pointer will break strict-aliasing rules

And, it finally died with:

magick/.libs/libMagickCore.so: undefined reference to `InstantiateXComponent'
collect2: ld returned 1 exit status
make[1]: *** [utilities/animate] Error 1
make[1]: Leaving directory `/usr/src/ImageMagick-6.5.7-1'
make: *** [all] Error 2

Attempt 2:

I removed the ImageMagick-6.5.7-1 directory, untarred again, and tried installing according to the instructions here: http://www.imagemagick.org/script/install-source.php with a simple ./configure and make. Same results.

I can certainly do the work around with the older version of ImageMagick that comes with Centos 5.4 (great info!), but would prefer to get this upgrade working -- not only so I learn something, but hopefully to benefit anyone else trying to do the same thing (btw, this thread has already been picked up by google). Any suggestions...?

Thanks again,

-Ben

Re: resizing and padding problem in Centos 5.4

Posted: 2009-10-25T13:46:35-07:00
by magick
Edit magick/magick.c and comment out InstantiateXComponent:
  • // InstantiateXComponent();
We'll fix this problem in the next point release of ImageMagick.

Re: resizing and padding problem in Centos 5.4

Posted: 2009-10-26T08:34:27-07:00
by outdoorben
That did the trick. Thank you!

-Ben