Commandline PHP display to screen

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
AnthonyK

Commandline PHP display to screen

Post 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
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Commandline PHP display to screen

Post 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);
?>
AnthonyK

Re: Commandline PHP display to screen

Post by AnthonyK »

Your a star, both worked.
you missed one " off the 2nd one but easy to find.

Thx
Post Reply