use strict; use warnings; use Time::HiRes 'time'; use Imager; my $t = time; my $i = Imager-> new( file => 'file.jpg' ); printf "image dimensions: %d x %d\n", $i-> getwidth, $i-> getheight; printf "reading: %.2f s\n", time - $t; $t = time; $i-> copy -> scale( xpixels => 750, qtype => 'normal' ) -> write( file => 'file+.jpg' ); printf "high quality resize & save: %.2f s\n", time - $t; $t = time; $i-> copy -> scale( xpixels => 750, qtype => 'mixing' ) -> write( file => 'file+.jpg' ); printf "medium quality resize & save: %.2f s\n", time - $t; $t = time; $i-> copy -> scale( xpixels => 750 * 4, qtype => 'mixing' ) -> scale( xpixels => 750, qtype => 'normal' ) -> write( file => 'file+.jpg' ); printf "medium+ quality resize & save: %.2f s\n", time - $t; $t = time; $i-> copy -> scale( xpixels => 750, qtype => 'preview' ) -> write( file => 'file+.jpg' ); printf "low quality resize & save:\t\t %.2f s\n", time - $t; $t = time; $i-> copy -> rotate( right => -90 ) -> write( file => 'file+.jpg' ); printf "fast rotate & save: %.2f s\n", time - $t; $t = time; $i-> copy -> rotate( degrees => -90 ) -> write( file => 'file+.jpg' ); printf "slow rotate & save: %.2f s\n", time - $t; __END__ image dimensions: 6083 x 4636 reading: 1.23 s high quality resize & save: 6.52 s medium quality resize & save: 1.17 s medium+ quality resize & save: 3.84 s low quality resize & save: 0.58 s fast rotate & save: 3.41 s slow rotate & save: 19.33 s

Some options were introduced for a reason... + Use medium size image as source for thumb (not shown above).

Updated: GD is so much faster, what do you mean "messed with colors"? Should work fine for geometric transformations.

use strict; use warnings; use Time::HiRes 'time'; use GD; my $t = time; my $i = GD::Image-> newFromJpeg( 'file.jpg', 1 ); printf "image dimensions: %d x %d\n", $i-> getBounds; printf "reading: %.2f s\n", time - $t; for ( 1 .. 20, 22, 23 ) { $t = time; $i-> interpolationMethod( $_ ); $i-> copyScaleInterpolated( 750, 572 ) -> _file( 'file+.jpg' ); printf "resize method \"$_\" & save: %.2f s\n", time - $t; } $t = time; $i-> copyRotateInterpolated( 90, 0 )-> _file( 'file+.jpg' ); printf "rotate & save: %.2f s\n", time - $t; __END__ image dimensions: 6083 x 4636 reading: 1.47 s resize method "1" & save: 0.59 s resize method "2" & save: 0.62 s resize method "3" & save: 0.07 s resize method "4" & save: 0.25 s resize method "5" & save: 0.24 s resize method "6" & save: 0.55 s resize method "7" & save: 0.53 s resize method "8" & save: 0.55 s resize method "9" & save: 0.55 s resize method "10" & save: 0.55 s resize method "11" & save: 0.53 s resize method "12" & save: 0.55 s resize method "13" & save: 0.55 s resize method "14" & save: 0.55 s resize method "15" & save: 0.53 s resize method "16" & save: 0.04 s resize method "17" & save: 0.54 s resize method "18" & save: 0.58 s resize method "19" & save: 0.62 s resize method "20" & save: 0.59 s resize method "22" & save: 0.09 s resize method "23" & save: 0.12 s rotate & save: 3.03 s

Interpolation constants here. 21st died on me.


In reply to Re: Imager: Gateway Timeout (updated (GD)) by vr
in thread Imager: Gateway Timeout by cristofayre

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.