Bug #18459 Updated: Crashes When using pdf_open_image_file() with a tiff

From: Date: Tue, 23 Jul 2002 19:24:18 +0000
Subject: Bug #18459 Updated: Crashes When using pdf_open_image_file() with a tiff
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-14934@lists.php.net to get a copy of this message
ID: 18459 Updated by: sniper@php.net Reported By: sramage@fatpipeinternet.com -Status: Open +Status: Feedback Bug Type: PDF related Operating System: FreeBSD PHP Version: 4.2.1 New Comment: There was some problem with PDFlib and TIFFs.. The patch to fix that doesn't seem to be available anymore (there is 4.0.3 release already). Please update your pdflib and try again, I can not reproduce the crash. Previous Comments: ------------------------------------------------------------------------ [2002-07-22 22:24:02] sramage@fatpipeinternet.com sorry last one was wrong 13 lines short as I could do =) $pdf = pdf_new(); if (pdf_open_file($pdf,"output.pdf")) { $image=pdf_open_image_file($pdf,"tiff","test.tif","page",1); $x=pdf_get_value($pdf,"imagewidth",$image); $y=pdf_get_value($pdf,"imageheight",$image); pdf_begin_page($pdf,$x,$y); pdf_place_image($pdf,$image,0,0,1); pdf_close_image($pdf,$image); pdf_end_page($pdf); pdf_save($pdf); pdf_close($pdf); pdf_delete($pdf); } ------------------------------------------------------------------------ [2002-07-22 22:20:32] sramage@fatpipeinternet.com $pdf = pdf_new(); if (pdf_open_file($pdf)) { $image=pdf_open_image_file($pdf,"tiff","test.tif","page",1); $x=pdf_get_value($pdf,"imagewidth",$image); $y=pdf_get_value($pdf,"imageheight",$image); pdf_begin_page($pdf,$x,$y); pdf_place_image($pdf,$image,0,0,1); pdf_close_image($pdf,$image); pdf_end_page($pdf); pdf_save($pdf); $data=pdf_get_buffer($pdf); pdf_close($pdf); pdf_delete($pdf); $fp=fopen($output_file,"w"); fwrite($fp,$data,strlen($data)); fclose($fp); } ------------------------------------------------------------------------ [2002-07-22 21:16:06] sniper@php.net Please provide a SHORT script...and by short we mean under 10 lines.. ------------------------------------------------------------------------ [2002-07-21 17:02:00] sramage@fatpipeinternet.com self contained code below here is link to a standard tiff file http://fatpipeinternet.com/test/before1.tif <?php @define ("DOCUMENT_TIFF", "tiff"); function TIFFtoPDF($input_file,$output_file=false){ if(file_exists($input_file)){ if(!$output_file){ $ext=strrev(strtok(strrev($input_file),".")); $core=strrev(strtok("")); $output_file=$core.".pdf"; } $pdf = pdf_new(); if (pdf_open_file($pdf)) { pdf_set_parameter($pdf, "warning", "true"); pdf_set_info($pdf, "Creator", "Automatic"); pdf_set_info($pdf, "Author", "Automatic"); pdf_set_info($pdf, "Title", basename($input_file)); pdf_set_info($pdf, "Subject", "Generated PDF Document"); $count=1; while($image=pdf_open_image_file($pdf,DOCUMENT_TIFF,$input_file,"page",$count)){ if($count>2){ break; } $x=pdf_get_value($pdf,"imagewidth",$image); $y=pdf_get_value($pdf,"imageheight",$image); pdf_begin_page($pdf,$x,$y); pdf_place_image($pdf,$image,0,0,1); pdf_close_image($pdf,$image); pdf_end_page($pdf); $count++; } pdf_save($pdf); $data=pdf_get_buffer($pdf); pdf_close($pdf); pdf_delete($pdf); $fp=fopen($output_file,"w"); fwrite($fp,$data,strlen($data)); fclose($fp); $return=$output_file; }else{ $return=false; } }else{ $return=false; } } $passs_or_fail=""; if(is_array($_FILES)){ while(list($k,$file_array)=each($_FILES)){ if(file_exists($file_array["tmp"])){ if(TiffToPDF($file_array["tmp"],"tiff_to_pdf_test.pdf")){ $pass_or_fail="PASSED<iframe width=\"500\" height=\"200\" src=\"tiff_to_pdf_test.pdf\"></iframe>"; }else{ $pass_or_fail="couldn't Convert TIFF to PDF"; } }else{ $pass_or_fail="File didn't upload"; } } } $output="$pass_or_fail<BR><form enctype=\"multipart/form-data\" action=\"\" method=\"post\">Send this file: <input name=\"userfile\" type=\"file\"><input type=\"submit\" value=\"Send File\"></form>"; echo $output; ?> ------------------------------------------------------------------------ [2002-07-21 14:04:27] derick@php.net Then provide a short selfcontained script that reproduces the problem so that we can try it. Derick ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/18459 -- Edit this bug report at http://bugs.php.net/?id=18459&edit=1

« previous php.bugs (#14934) next »