Page 1 of 1

Commandline PHP display to screen

Posted: 2008-04-20T12:39:15-07:00
by AnthonyK
I'm trying to create/aulter an image in PHP and have it appear on the screen without creating a file on my server. ATM i can use a commandline string to produce an png file so i know imagemagick is working and that somthing can be produced.
My code for this is:

Code: Select all

exec("/usr/bin/convert -size 100×60 xc:none -fill red -draw 'circle 25,30 10,30' \
-draw 'circle 75,30 90,30' -draw 'rectangle 25,15 75,45' gel_shape.png");
I thought changing the last gel_shape.png to x: it would work but it han't. Any help?

btw i got the inital code from a tutorial site but they didnt cover this

Re: Commandline PHP display to screen

Posted: 2008-04-20T13:28:40-07:00
by Bonzo
Give this a go:

Code: Select all

<?php
system("convert -size 100×60 xc:none -fill red -draw \"circle 25,30 10,30\" -draw \"circle 75,30 90,30\" -draw \"rectangle 25,15 75,45\" PNG:-");
?>
This code MUST be the first thing on the page.

Or you can modify this code and put it on a page of its own and call with <img src="page_code_is_on.php">

Code: Select all

<?php
$cmd = convert -size 100×60 xc:none -fill red -draw \"circle 25,30 10,30\" -draw \"circle 75,30 90,30\" -draw \"rectangle 25,15 75,45\" PNG:-";

header("Content-type: image/jpeg");
passthru($cmd, $retval);
?>

Re: Commandline PHP display to screen

Posted: 2008-04-20T15:22:40-07:00
by AnthonyK
Your a star, both worked.
you missed one " off the 2nd one but easy to find.

Thx