Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^9: Perl Image Analysis

by lparsons42 (Novice)
on Oct 06, 2006 at 22:04 UTC ( [id://576762]=note: print w/replies, xml ) Need Help??


in reply to Re^8: Perl Image Analysis
in thread Perl Image Analysis

Actually, a closer inspection revealed that I had an earlier line in the script that I had forgotten that told it I was looking at Jpg files:
my $MyImage = GD::Image->newFromJpeg($file, 0);
I found that of course if I changed that line instead to
my $MyImage = GD::Image->newFromPng($file, 0);
That it will then happily read PNG files. Had I remembered having set GD to read Jpeg files, I probably would have realized that one earlier. Of course, the errors telling me that the file wasn't Jpeg probably should have clued me in, as well...

Replies are listed 'Best First'.
Re^10: Perl Image Analysis
by BrowserUk (Patriarch) on Oct 06, 2006 at 22:27 UTC

    If you use

    $image = GD::Image->new($filename)

    It will work out what type of image it is for itself--modulo those types it supports. A quick look at the docs didn't reveal any mention of .tiff though. .png is my preference anyway, as it compresses very well without any artifacts or side effects other than taking a few more milliseconds to load.

    By way of example:

    • A 66 MB 6600x3400 24-bit tiff containing 1565866 colours, which takes 1/3rd of a second to load.
    • Saved as a 24-bit .png with maximum compression reduces to 44 MB.

      Still contains 1565866 colours and shows no signs of of any artifacts even at 500% magnification. but it takes 3 seconds to load (and decompress).

    • Saved as a 24-bit .jpg at 'best' quality, it reduces to 20 MB.

      But now only contains 650125 colours, shows clear signs of the lossy algorithm even at modest magnifications and still takes 2 seconds to load (and decompress).


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://576762]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2024-04-20 00:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found