harsha has asked for the wisdom of the Perl Monks concerning the following question:

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"; }