Since your code above looks a lot like something I did, I should point out the resize routine in my
pic thresher application. You won't find any improvements to the resizing bit, but you may find it helpful in other ways.
My cursory tests indicate that the subsample argument is an integer deal. It seems it literally plucks out every
nth pixel.
There is a 'zoom' option in the $Photo->copy() method, which you might use to first enlarge the image, then shrink it back down. For instance, to get to 67% image size, you would zoom by 2 then subsample by 3. For 75%, zoom by 3, then subsample by 4. I've never had the urge to try this, as it seems like a guarantee for some ugly images. {grin} (not to mention the mental agony required to make a table of all these zoom/subsample ratios).
Tk::Photo also has a $Photo->get(x, y) method, which you could use to grab information about specific sets of pixels, then create new smaller sets of pixels from. So to get a 75% reduction grab a 4x4 "cell" from the image, then use your favorite algebraic formulas to compute corresponding values for a 3x3 "cell". Iterate until you have run out of cells. I'm guessing that using any of the other graphics modules would be more fun than this-- tempting as I'm sure the exercise sounds. Suggested module:
GD.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.