Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Gif image corrupted

by vasanthgk91 (Sexton)
on Nov 24, 2012 at 11:23 UTC ( #1005364=perlquestion: print w/replies, xml ) Need Help??
vasanthgk91 has asked for the wisdom of the Perl Monks concerning the following question:

This gif image generated through GD:Graph module.I checked normal image converted successfully..This gif image only i have a problem.when i convert img to pdf..that is corrupted why?
use PDF::API2; my $pdffile=$harddriveroot.$projectname."/sample.pdf"; my $img_money_graph=$harddriveroot.$projectname."/codedata/chart/$fold +er_name/$username\_money.gif"; my $page1 = $pdf->page; $page1->mediabox('A4'); my $photo1 = $page1->gfx; my $photo_file1 = $pdf->image_gif($img_money_graph); $photo1->image( $photo_file1,20,360,560,450); $pdf->saveas($pdffile); $pdf->end();

Replies are listed 'Best First'.
Re: <p>Gif image corrupted?</p>
by zentara (Archbishop) on Nov 24, 2012 at 11:33 UTC
    I don't have the GD gif that you start with, but my guess from looking at the code, is that you are giving the wrong dimensional information in your $photo_file1 options. This is consistent with your Chatterbox description that if you resize the image, the distortion is less. Use the following code to get the real height and width of your GD produced gif.
    #!/usr/bin/perl use warnings; use strict; use GD; my $image = GD::Image->newFromJpeg("frontpage.jpg"); my ($width,$height) = $image->getBounds(); print "width->$width\nheight->$height\n"; exit;
    P.S. Also, please put a problem description in your original question, so others who didn't see the Chatterbox stuff, will know what your problem is.

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh
Re: Gif image corrupted
by jms53 (Monk) on Nov 24, 2012 at 12:11 UTC
    Depending on what system you're on, there are tools that do the conversion job.
    If you are on a Linux machine, try replacing your pdf conversion process with the following:
     `inkscape -f input.gif -A output.pdf`
    I have no proof that this will work on Mac OSX, and I am certain it will not work on windows.
    J -

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1005364]
Approved by kcott
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2017-08-19 23:46 GMT
Find Nodes?
    Voting Booth?
    Who is your favorite scientist and why?

    Results (312 votes). Check out past polls.