Resize with space Fill

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
avvllvva

Resize with space Fill

Post by avvllvva »

Hi,

Can anybody tell what is wrong with following php code for resizing image with space fill?

Code: Select all

<?php
exec($path_to_convert." ".$imagePath." -resize 80x80 -size 80x80 xc:blue +swap -gravity center  -composite ".$newPath);
?>	
This is working perfectly in local machine but not in server.

Note:- My server have Imagick S/W and its working perfectly with another methods like simple resizing, aspect ratio etc.

I tried examples from http://www.imagemagick.org/Usage/resize/#space_fill

Thanks
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Resize with space Fill

Post by Bonzo »

See if you get an error running like this :

Code: Select all

<?php
$array=array();
echo "<pre>";
exec($path_to_convert." ".$imagePath." -resize 80x80 -size 80x80 xc:blue +swap -gravity center  -composite ".$newPath 2>&1", $array); 
echo "<br>".print_r($array)."<br>"; 
echo "</pre>";
?>
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Resize with space Fill

Post by fmw42 »

you could also try

convert image -resize 80x80 -gravity center -background blue -extent 80x80 result

or

convert monet3.jpg -resize "80x80^" -gravity center -crop 80x80+0+0 +repage result

if on windows see notes about ^ at http://www.imagemagick.org/Usage/windows/
avvllvva

Re: Resize with space Fill

Post by avvllvva »

Hi Bonzo, this is the output

Array
(
[0] => convert: Unrecognized option (+swap).
)

1

------------------------------------------
also no luck with fmw42 soln
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Resize with space Fill

Post by Bonzo »

What version is on the server compaired to your local machine ?
Post Reply