Imagemagik problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Jim
Forum Contributor
Posts: 238
Joined: Fri Apr 19, 2002 5:26 am
Location: Near Austin, Texas

Imagemagik problem

Post by Jim »

Code: Select all

function resize_image( $width , $height , $quality , $srcfile , $dstfile )
	{
		$imagemagik = "/usr/X11R6/bin";
		$src_file = $srcfile;
		$dest_file = $dstfile;
		$qual = $quality;
		$h = $height;
		$w = $width;
		


		$cmd = "{$imagemagik}/convert -quality {$qual}  -geometry {$w}x{$h} $src_file $dest_file";
		$do = exec($cmd);
		
		if (!$do) { echo "This didn't work."; }
		
	}

The function works fine - but when width and height arguments are added to the function, the height argument is ignored.

I did some checking, and both the width and height arguments are passed properly in to the function.. not sure why they aren't both being accepted though.

Any ideas anyone?
User avatar
BDKR
DevNet Resident
Posts: 1207
Joined: Sat Jun 08, 2002 1:24 pm
Location: Florida
Contact:

Post by BDKR »

Did you try hacking the command out at the command line? Perhaps seeing the output (if any) could give you some clue as to what's going on.

Cheers,
BDKR
User avatar
xisle
Forum Contributor
Posts: 249
Joined: Wed Jun 25, 2003 1:53 pm

Post by xisle »

from the manual..
http://www.imagemagick.org/www/utilitie ... s-geometry
By default, the width and height are maximum values. That is, the image is expanded or contracted to fit the width and height value while maintaining the aspect ratio of the image. Append an exclamation point to the geometry to force the image size to exactly the size you specify. For example, if you specify 640x480! the image width is set to 640 pixels and height to 480.
try the exclamation point for an exact dimension.. beware of squashing...
Jim
Forum Contributor
Posts: 238
Joined: Fri Apr 19, 2002 5:26 am
Location: Near Austin, Texas

Post by Jim »

I love you.
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post by dull1554 »

wow aren't we thankful
Post Reply