php and convert problem with some images

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
ccristi77

php and convert problem with some images

Post by ccristi77 »

Hi,
I have this img
https://docs.google.com/leaf?id=0B4Zy8e ... y=CI6I09MM

When calling from command bellow line is working ok.
convert a.jpg -resize 420x420 b.jpg

When calling via php
exec("convert a.jpg -resize 420x420 b.jpg") is not working. Is crashing with OutOfMemory

If I call from php
exec("convert a1.jpg -resize 420x420 b.jpg") and a1 is generated from command line with
convert a.jpg a1.jpg is working ok.

Can anyone tell me what is wrong with this image and also if there is a workaround for bellow issue to have same result with php ?

Thank You
Cristi
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: php and convert problem with some images

Post by anthony »

PHP is a different environment, with different command PATH, called in a different directory, and sometimes by a different user.

See IM Examples, APIs, PHP
http://www.imagemagick.org/Usage/api/#php
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
ccristi77

Re: php and convert problem with some images

Post by ccristi77 »

Hi,
Thank you for replay. I tried some new stuff I learned from the link you gave but still is not working.
Other images with same command, bigger or smaller than this are working, just few images are not working.
In php error log I see
"convert: Insufficient memory (case 4) `tarr.jpg'. convert: missing an image filename `tarr1.jpg'. "

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

Re: php and convert problem with some images

Post by Bonzo »

Why when I look at the image on your link using IE, firefox, chrome ( gave up with Safari as it would not even load the page ) is there just a blank page?
When I download it I can see it on my PC!

I can convert it OK using a localhost on my PC but again it will not show up in my browser but I can see it in the folder.

Code: Select all

<?php 
$array=array(); 
echo "<pre>";
system("identify -verbose a.jpg" );
exec("convert a.jpg -resize 420x420 b.jpg 2>&1", $array);  
echo "<br>".print_r($array)."<br>";  
echo "</pre>"; 
?>
<img src="b.jpg">
I would say that there is a problem with a the image and b your php setup.

Try running my code and see waht you get - compair the image information output with an image that is OK.
Post Reply