Hello monks,

This is sriharsha. I am writing an email parser. It's executing fine but it's taking too much time, as i have some performance issues. What I am doing is I have to parse an email and if it contains image file I have to save it. During this process, I am extracting the email attachment using Email::MIME::Attachment::Stripper. It returns an array of attachments that contains { filename, content_type, pay_load }. I am writing pay_load to a file and then reading that file using Image::Magick doing necessary operations like resizing. This process is taking lot of time. What I want to do is instead of writing the pay_load to file, I want to read pay_load directly with Image->Read($attachment->{pay_load}), but the image is not creating. Can you suggest to me a better option.

Thank you monks.

The code is:

if ($attachments->{content_type} =~ m/jpe?g|png/i) { #Image Processing my $pic=Image::Magick->new(); $pic->ReadImage($attachment->{pay_load}); $pic->Resize(geometry=>"240x240"); $pic->write($absolute_thumbnail_path); $pic->Resize(geometry=>"480x480"); $pic->write($absolute_baseimage_path); } else { print "\n it's not a jpg or png\n"; }

In reply to problems with Perl Magick reading attachment->{payload} by harsha

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.