Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

How can I predict which image will big smaller ?

by palkia (Scribe)
on Aug 03, 2012 at 14:34 UTC ( #985250=perlquestion: print w/ replies, xml ) Need Help??
palkia has asked for the wisdom of the Perl Monks concerning the following question:

Hi everyone.
I'm trying to find a way to predict which image (Imager)
will take the smaller size once saved to a file (before saving).
Since I'm planning this process to run many times,
I don't want to slow down my program by actually saving the images to files and than comparing sizes, and removing the bigger one.

Your thoughts ?
Thx

Comment on How can I predict which image will big smaller ?
Re: How can I predict which image will big smaller ?
by BrowserUk (Pope) on Aug 03, 2012 at 14:55 UTC

    Why not have it write all the filetypes to a ramfile first:

    my %sizes; for my $type ( Imager->write_types ) { open my $ramFH, '>:raw', \$buffer; $im->write( fh => $ramFH, type => $type ); $sizes{ length $buffer } = $type; } ## Pick type of smallest my $filetype = $sizes{ (sort{ $a <=> $b } keys %sizes)[0] }; ## write to real file ...

    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    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.

    The start of some sanity?

Re: How can I predict which image will big smaller ?
by ww (Bishop) on Aug 03, 2012 at 15:06 UTC
    Did you read the documentation?
    ... especially
    # try to save in one of these formats
    SAVE:
    "
    (assumption: you mean smaller file size).

    Or, "# Create smaller version
    # documented in Imager::Transformations
    "
    if "smaller size" refers to dimensions in pixels.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://985250]
Approved by BrowserUk
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (18)
As of 2014-07-23 14:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (144 votes), past polls