resize option flag '^' does not work in PHP?
resize option flag '^' does not work in PHP?
As it seems the resize option flag '^' does not work within the PHP environment. It does work when the command is executed via SSH shell so it must be related to PHP.
I have tried several commands and right now I am trying the folowing:
exec("convert -size 300x300 ".$image_loc." -thumbnail 100x100^ -gravity center -crop 100x100+0+0 +repage ".$image_loc."");
Is this a bug?
Thanks in advance for your help!
I have tried several commands and right now I am trying the folowing:
exec("convert -size 300x300 ".$image_loc." -thumbnail 100x100^ -gravity center -crop 100x100+0+0 +repage ".$image_loc."");
Is this a bug?
Thanks in advance for your help!
Re: resize option flag '^' does not work in PHP?
Try enclosing the part of code in " or '
or
Code: Select all
exec("convert -size 300x300 $image_loc -thumbnail \"100x100^\" -gravity center -crop 100x100+0+0 +repage $image_loc");
Code: Select all
exec("convert -size 300x300 $image_loc -thumbnail '100x100^' -gravity center -crop 100x100+0+0 +repage $image_loc");
Re: resize option flag '^' does not work in PHP?
Thank you for your reply! However, I already tried that and I just used your above examples to try it again and it didn't work.Bonzo wrote:Try enclosing the part of code in " or '
orCode: Select all
exec("convert -size 300x300 $image_loc -thumbnail \"100x100^\" -gravity center -crop 100x100+0+0 +repage $image_loc");
Code: Select all
exec("convert -size 300x300 $image_loc -thumbnail '100x100^' -gravity center -crop 100x100+0+0 +repage $image_loc");
When I try it in SSH it does work for some reason.
Re: resize option flag '^' does not work in PHP?
When running my first example on my server at home ( XAMPP on windows XP ) the first example I posted worked. But it will not work on the server my site is on; I have tried escaping the ^ and it still will not work.
I wonder if it is a version problem ?
convert: invalid argument for option `100x100^': -resize.
6.4.0 04/16/08 Q16 at home and 6.3.5 08/29/07 Q16 on my server.
I wonder if it is a version problem ?
convert: invalid argument for option `100x100^': -resize.
6.4.0 04/16/08 Q16 at home and 6.3.5 08/29/07 Q16 on my server.
Re: resize option flag '^' does not work in PHP?
Well, for me the server is already upgraded to the latest version and it does work from shell (SSH). Just not from within PHP.Bonzo wrote:When running my first example on my server at home ( XAMPP on windows XP ) the first example I posted worked. But it will not work on the server my site is on; I have tried escaping the ^ and it still will not work.
I wonder if it is a version problem ?
convert: invalid argument for option `100x100^': -resize.
6.4.0 04/16/08 Q16 at home and 6.3.5 08/29/07 Q16 on my server.
Re: resize option flag '^' does not work in PHP?
Do you get the same error as me ?
I also tried escaping the ^ with ^ as somebody else had a similar problem and that worked for them but not for me.
Code: Select all
echo "<pre>";
$array = array();
exec("convert -size 300x300 $image_loc -resize 100x100^ -gravity center -crop 100x100+0+0 +repage $image_loc 2>&1", $array);
echo "<pre>";
print_r($array);
echo "</pre>";
Re: resize option flag '^' does not work in PHP?
I am not seeing any errors, I believe error reporting for exec()/system() calls is disabled for security reasons.
Re: resize option flag '^' does not work in PHP?
I can not get anything to work; I think you will have to do a bit more work with php:
Code: Select all
<?php
$size = getimagesize( $image_loc );
if ( $size[0] > $size[1] ){
$size = "x100"; }
else { $size = "100x"; }
$cmd = "-size 300x300 $image_loc -resize $size -gravity center -crop 100x100+0+0 +repage";
exec("convert $cmd $image_loc");
?>
Re: resize option flag '^' does not work in PHP?
Yes, that seems to be a good solution! I will try it!Bonzo wrote:I can not get anything to work; I think you will have to do a bit more work with php:
Code: Select all
<?php $size = getimagesize( $image_loc ); if ( $size[0] > $size[1] ){ $size = "x100"; } else { $size = "100x"; } $cmd = "-size 300x300 $image_loc -resize $size -gravity center -crop 100x100+0+0 +repage"; exec("convert $cmd $image_loc"); ?>
Thanks a lot for your help!
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: resize option flag '^' does not work in PHP?
FYI:
The ^ for resize was added in version 6.3.8-2 according to the changelog
The ^ for resize was added in version 6.3.8-2 according to the changelog
Re: resize option flag '^' does not work in PHP?
I thought it had been around a lot longer than that. As I said in another post it works at home on 6.4.0 04/16/08 Q16 and not 6.3.5 08/29/07 Q16 on my server, that pressumably is why !
At least there is a simple way around it using a bit more php.
At least there is a simple way around it using a bit more php.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: resize option flag '^' does not work in PHP?
Also note that ^ is a special character for Windows batch scripts. It may not work as expected for PHP on a windows box.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/