I use a command-line executable that returns the byte stream of a TIFF image. Some of these images are multi-page TIFFs. I want to ultimately display this image inside a PDF document.
There are plenty of examples for PDFlib on how to insert an image that is stored as a file, but very few on how to insert one from memory. I believe the process would be to use the PHP Image functions (which use the GD library) to create an image in memory from the TIFF byte stream. This object would then be loaded into a new PDF using the PDFlib functions.
So I want to do something like this:
// retrieve tiff image byte stream (retrieve contents of tiff)
$tiff = `getimg .....`;
$img = imagecreatefromstring($tiff);
// $pdf is a new pdf object
$pim = pdf_open_memory_image($pdf, $img);
imagedestroy($img);
pdf_place_image($pdf, $pim, 100, 100, 1);
pdf_close_image($pdf, $pim);
When I execute the above code, I get this message:
PHP Warning: imagecreatefromstring() [http://www.php.net/function.imagecreatefr
omstring]: Data is not in a recognized format. in /usr/local2/apache/htdocs/php/
pdf.php on line 16
Looks like TIFF images are a little harder to deal with....
Any pointers would be appreciated.....thanx