matua105 has asked for the wisdom of the Perl Monks concerning the following question:

I am using the following to call a png image from a directory

$image = GD::Image->newFromPng($container);

The image displays, however the resolution is poor. How do I increase the quality of the resolution of the png?

Lincoln Stein's GD website says that if the original png is in true color it will display in true color, but that is not happening here.

Being a newbie, I have tried to implement the truecolor method but I am getting an internal server error most likely because I am doing it wrong.

Can the monks help me here? Thanks in advance for your wisdom.

*******

Thanks to all who gave their input on this issue. I changed all the pngs to jpgs and this solved the resolution problem. I looked at all the png information on the net via google, downloaded gimp and followed the advice there to use jpegs instead of pngs.

Replies are listed 'Best First'.
Re: GD:image resolution issue
by zentara (Cardinal) on Aug 10, 2010 at 21:00 UTC

      Thanks for your quick response!

      I tried it but i still get an internal server error

      #!/usr/local/bin/perl use GD; use CommonSubs; $user = $ENV{'REMOTE_USER'}; %availableCards = ("card1" => "/tech/performance-culture +/rewards/images/ecards-master/large_card_1.png", "card2" => "/tech/p +erformance-culture/rewards/images/ecards-master/large_card_2.png", "card3" => "/tech/p +erformance-culture/rewards/images/ecards-master/large_card_3.png", "card4" => "/tech/p +erformance-culture/rewards/images/ecards-master/large_card_4.png", "card5" => "/tech/p +erformance-culture/rewards/images/ecards-master/large_card_5.png", "card6" => "/tech/p +erformance-culture/rewards/images/ecards-master/large_card_6.png", "card7" => "/tech/p +erformance-culture/rewards/images/ecards-master/large_card_7.png", "card8" => "/tech/p +erformance-culture/rewards/images/ecards-master/large_card_8.png", "card9" => "/tech/p +erformance-culture/rewards/images/ecards-master/large_card_9.png"); $cardToUse = $availableCards{'card7'}; $text = "Hello Cy,\nGreat job! You are an asset to Cisco\nand your org +anization.\nRegards,\nCarlo"; @lines = split(/\n/, $text); $lCnt .= $#lines+1; $lineStart = 80; $lineHeight = 24; $container = "/opt/httpd/root-wwwin/htdocs".$cardToUse; $font = "/opt/httpd/root-wwwin/data-priv-shared/ops/web/LPG/templ/verd +ana.ttf"; $image = GD::Image->newFromPng($container,1); $txtColor = $image->colorResolve(0,0,0); for ($i=0; $i<$lCnt; ++$i){ $xPos = 375; $yPos = $lineStart + ($lineHeight*$i); @bounds = $image->stringTTF($txtColor,$font,13,0,$xPos,$yPos,@line +s[$i]); } $ts = time(); $imgFile = "ecard_".$user."_".$ts.".png"; open(IMGFILE, ">/opt/httpd/root-wwwin/data-shared/tech/artg/cust-touch +/videos/$imgFile"); binmode IMGFILE; print IMGFILE $image->png; close (IMGFILE); $img = "<img border=0 src=\"/data-shared/tech/artg/cust-touch/videos/$ +imgFile\" />"; print "Content-type: text/html\n\n"; print "$img";

        I tried it but i still get an internal server error

        Check your logs for the error you get.

Re: GD:image resolution issue
by BrowserUk (Patriarch) on Aug 10, 2010 at 21:07 UTC

    Maybe:

    $image = GD::Image->newFromPng( $container, 1 );

    But also, what version of GD do you have?


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

      Thanks for your quick response!

      I tried your solution but I still got an internal error message.

      Where can I find the GD module. I am in a large bu.

      Thanks again for your help.
        I am in a large bu.

        What is a "large bu"?

        To find out the version you have installed, do:

        perl -MGD -le"print $GD::VERSION" 2.44

        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.