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

CommentFileSizeAuthor
#7 130016.patch992 bytesdouggreen

Comments

John Bryan’s picture

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

rconstantine’s picture

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

panis’s picture

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.

bigcrunch’s picture

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

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

rconstantine’s picture

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

bigcrunch’s picture

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

douggreen’s picture

StatusFileSize
new992 bytes

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