I did ... but not in the way it is specified in the manual of Imager::Files. Thanks for hinting it is possible as I was convinced it wasn't and did not perservere with the manuals ... (maybe they should put this important info under the heading read() or in the Description section of mod:://Imager). The following works for me:

use strict; use warnings; use Imager; use Imager::Filter::Autocrop; my $imgdata = undef; open(IN, '<', 'example.jpg'); binmode(IN); { local $/ = undef; $imgdata = <IN> } close(IN); my $img = Imager->new(); # possible params are 'file', 'data' and 'fd' $img->read(data=>\$imgdata) or die "read: ".$img->errstr(); $img->filter(type=>'autocrop', fuzz=>20) or die "autocrop: ".$img->err +str(); $img->write(file=>'out.jpg') or die "writing: ".$img->errstr();

Edit: actually it is not documented in Imager::Files that data is a recognised input param name for read(). It is only mentioned in the write(). Anyway, all well now.


In reply to Re^2: Imager : read image from scalar (not from file) by bliako
in thread Imager : read image from scalar (not from file) by bliako

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.