.gif breaks tcpdf.. Skip them?
shadyman@errora... - March 22, 2007 - 07:39
| Project: | Pdfview |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Description
Since GIF doesn't work in TCPDF.. Could there be some kind of process to ignore .gif? I know the smilies module especially uses GIFs a lot, and if you try to make pdf, you get
TCPDF error: Unsupported image type: gif

#1
Suffered similar but skip GIFs not an option in my case, but found some code elsewhere.
Try editing the tcpdf.php file and insert the following immediately after the functionstatement for the "image" routine:-
public function Image($file, $x, $y, $w=0, $h=0, $type='', $link='') {
$tmp_img = getImageSize($file);
if ($tmp_img[2] == '1') {
$tmp_filename = tempnam('/tmp/', 'gif4fpdf'.md5(uniqid(rand())) );
$img = imagecreatefromgif($file);
imageinterlace($img,0);
imagepng($img, $tmp_filename);
rename($tmp_filename, $tmp_filename.'.png');
$file = $tmp_filename.'.png';
$type = 'png';
}
This should provide a cack handed way to get GIFs displayed and gets around a transparency/interlace problem with TCPDF/FPDF
#2
Where do the image functions, such as imagecreatefromgif come from? Another module? GD?
#3
GD functions. You can extend the TCPDF class see http://www.hyrme.com for a similar approach but within the tcpdf framework which allows you to write any _parseXXX hook.
#4
It is possible convert Gif images to Png with 'gif_outputAsPNG' function or similar?
An example: http://es.php.net/imagecreatefromgif
#5
That's exactly what the code above does, 4th line down.
#6
This code works, but the images come out very small.
#7
The attached file (to be applied against tcpdf) might help someone. I confirm that the patch fixes the problem.