php - Outputting multiple jpegs dynamically created, into webpage -



php - Outputting multiple jpegs dynamically created, into webpage -

so have code can create jpeg rectangle.

<?php // create 200 x 200 image $canvas = imagecreatetruecolor(1000, 500); // allocate colors //$pink = imagecolorallocate($canvas, 255, 105, 180); $white = imagecolorallocate($canvas, 255, 255, 255); //$green = imagecolorallocate($canvas, 132, 135, 28); // draw 3 rectangles each own color //imagerectangle($canvas, 50, 50, 150, 150, $pink); //imagerectangle($canvas, 100, 120, 75, 160, $green); imagerectangle($canvas, 0, 0, 120, 100, $white); // output , free memory header('content-type: image/jpeg'); imagejpeg($canvas); imagedestroy($canvas); ?>

is there way, can run in loop multiple rectangles outputted webpage.

please note: not want multiple rectangles in same canvas. want canvas rectangle in it. next canvas rectangle in it, etc. tried running in loop, not seem work

no, can't purely php. can output single image, , explicitly state 'i not want multiple rectangles in same canvas'.

you need create multiple references in html, passing parameters used php in creating image:

<img src="/path/to/php?width=100&height=200"> <img src="/path/to/php?width=200&height=100"> <img src="/path/to/php?width=500&height=500"> ...

and in php (this example; validate parameters!):

$canvas = imagecreatetruecolor($_get['width'], $_get['height']); ...

php loops header jpeg gd

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -