in reply to Including GIF image into PDF (using GD::Graph and PDF::API2 libraries)

I have to wonder: Why even create the GIF file at all?

####Remove this snippet:

open (MYFILE, '>test.gif');
binmode MYFILE;
print MYFILE $gd->gif();
close (MYFILE);

#### and change this line:

my $photo_file = $pdf->image_gif('test.gif');

#### to this:

my $photo_file = $pdf->image_gd($gd);

That way you don't have a gif file floating around, it is created directly into the PDF.
  • Comment on Re: Including GIF image into PDF (using GD::Graph and PDF::API2 libraries)

Replies are listed 'Best First'.
Re^2: Including GIF image into PDF (using GD::Graph and PDF::API2 libraries)
by Anonymous Monk on Apr 30, 2010 at 14:45 UTC
    Going back to the original post, there does appear to be a bug in the GIF reader in PDF::API2, which causes it to decompress larger size GIF files incorrectly. I managed to trace through and fix it for my project. The relevant library file GIF.pm, version 2.0, 2005/11/16 contains an error in line 135. The patch is as follows:
    C<< 135c135 < $bits++ if($nextcode == (1<<$bits)); --- > $bits++ if($nextcode == (1<<$bits) and $bits<12); >>
    I will submit this bug/fix to the package maintainer but in the meantime this post should help people who are stuck get their program working again.

      When generating submitting your patch, can you generate a .t file as well that exhibits the incorrect behavior in the original, but not the patched version.

      Not certain how you would do this, but there may be an example in the source .t files.

      --MidLifeXis

        there may be an example in the source .t files.

        JFYI, PDF::API2 test suite contains one file and it is called t/00use.t :)

      thanks a lot. works for me also.