tags:

views:

150

answers:

1

i have to create number of images with php GD library. but after calling imagejpeg(''name,'',100); The First image is generated and execution is halted with browser window showing the image generator file name.

does any body tell me how can i loop to create images in loop

my code looks like

<?php
// Including all required classes
require('class/BCGFont.php');
require('class/BCGColor.php');
require('class/BCGDrawing.php'); 

// Including the barcode technology
include('class/BCGcode39.barcode.php'); 

// Loading Font
$font = new BCGFont($cfg->doc_root.'/barcodegen/class/font/Arial.ttf', 10);

// The arguments are R, G, B for color.
$color_black = new BCGColor(0, 0, 0);
$color_white = new BCGColor(255, 255, 255); 

$code = new BCGcode39();
$code->setScale(1); // Resolution
$code->setThickness(30); // Thickness
$code->setForegroundColor($color_black); // Color of bars
$code->setBackgroundColor($color_white); // Color of spaces
$code->setFont($font); // Font (or 0)
#$text='hello';
$code->parse($text); // Text


/* Here is the list of the arguments
1 - Filename (empty : display on screen)
2 - Background color */
$drawing = new BCGDrawing($name, $color_white);
$drawing->setBarcode($code);
$drawing->setRotationAngle(90);
$drawing->setDPI(72);
$drawing->draw();

// Header that says it is an image (remove it if you save the barcode to a file)
header('Content-Type: image/jpeg');

// Draw (or save) the image into PNG format.
$drawing->finish(BCGDrawing::IMG_FORMAT_JPEG);
?>
+1  A: 

You can't output multiple files in the same response.*

You will have to write the files out to disk, possibly using a numbered naming scheme:

image1.jpg
image2.jpg
image3.jpg
image4.jpg
image5.jpg

and then include them one by one using <img src='...'>

* = there is the possibly of multipart responses, but they are not reliably supported yet.

Pekka
thanks pekka, but the execution is halted with first image generation and saving (i have to save them). but for next how can i do that thing
Naresh
You need to show some of your PHP code.
Pekka