...

View Full Version : can't create simple image from php exec , can create with the same command standalone



umen242
11-30-2010, 02:40 PM
I have this code running in CentOS 5.5 ,PHP 5.1.6 ,Apache/2.2.3 ,ImageMagick 6.2.8

$convert = "/usr/bin/convert";
$command = "$convert -size 100x100 xc:blue mytest.jpg";
$test_image = exec($command);
echo "<img src=\"mytest.jpg\">";

when i run the php tester i dont get the image created , only the echo string printed on page as html.
but when i run the same command as onliner the image does created just fine.

/usr/bin/convert -size 100x100 xc:blue mytest.jpg
what is wrong here i can't tell.

MattF
11-30-2010, 08:19 PM
Enable error_reporting and see what error message you get. Personally, I'm guessing user:group permissions.

Fou-Lu
11-30-2010, 09:39 PM
The description for the problem actually sounds like its being served as text/plain.
At the top of your page, try adding an html header:


header("Content-type: text/html");

I assumed that your output was:


<img src="mytest.jpg" />

and not


echo "<img src=\"mytest.jpg\" />";

right?

Also, be warned that exec() is often disabled for security reasons. If it is, you can use the PHP GD Library to alter your graphics.

umen242
12-01-2010, 03:48 AM
before the html



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum