resizing and padding problem in Centos 5.4

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
outdoorben

resizing and padding problem in Centos 5.4

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: resizing and padding problem in Centos 5.4

Post 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
outdoorben

Re: resizing and padding problem in Centos 5.4

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: resizing and padding problem in Centos 5.4

Post 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
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: resizing and padding problem in Centos 5.4

Post 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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
outdoorben

Re: resizing and padding problem in Centos 5.4

Post 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
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: resizing and padding problem in Centos 5.4

Post by magick »

Edit magick/magick.c and comment out InstantiateXComponent:
  • // InstantiateXComponent();
We'll fix this problem in the next point release of ImageMagick.
outdoorben

Re: resizing and padding problem in Centos 5.4

Post by outdoorben »

That did the trick. Thank you!

-Ben
Post Reply