.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

John Bryan - August 10, 2007 - 15:05

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

rconstantine - October 17, 2007 - 22:12

Where do the image functions, such as imagecreatefromgif come from? Another module? GD?

#3

panis - October 22, 2007 - 12:09

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

bigcrunch - October 24, 2007 - 10:42

It is possible convert Gif images to Png with 'gif_outputAsPNG' function or similar?

An example: http://es.php.net/imagecreatefromgif

#5

rconstantine - October 24, 2007 - 17:50

That's exactly what the code above does, 4th line down.

#6

bigcrunch - October 25, 2007 - 19:05

This code works, but the images come out very small.

#7

douggreen - January 17, 2008 - 22:58

The attached file (to be applied against tcpdf) might help someone. I confirm that the patch fixes the problem.

AttachmentSize
130016.patch992 bytes
 
 

Drupal is a registered trademark of Dries Buytaert.