[Thamesvalley-pm] MIME:Parser
Roger Bell_West
roger at firedrake.org
Tue Jul 19 01:13:50 PDT 2016
On Tue, Jul 19, 2016 at 03:12:12AM +0100, Andrew wrote:
>I mentioned it was a method of head, and not of the parser bit of Mime Tools
>I was using (use Mime::Parser;). Now back home, I figured I'd just write
>"head->" before "recommended_filename", .....and I'm guessing that would
>work.
Yes, that's the trick. It's been a while since I touched this but my
code has
my $type=$ent->effective_type;
my $file=$ent->head->recommended_filename;
>A quick google, and I learnt PDFs typically start with the characters %PDF
>before any binary or ascii kicks in.
Don't do it the hard way! If you do end up needing to do this, use
File::Type.
>from a trusted source,
Until their email address book leaks. They're using Microsoft after all.
>from an automated source [ so the message source is always structured the
>same ]
Until they change the software without telling you.
>I'll still try and clue myself up on File, and also hope to look into
>Imager, the latter of which is what Roger mentioned after I mentioned Image
>Magick.
There's also GD, which is a bit older, but I find that Imager covers
all the image manipulation I want to do. Creating a reduced-size image
with the same aspect ratio, which I think was what you were talking
about, is as simple as:
my $img=Imager->new(file => $in);
my $tn=$img->scale(xpixels => 512,
ypixels => 512,
type => 'min');
$tn->write(file => $out);
which will result in one no bigger than 512 pixels in either
dimension. Other options are available.
More information about the Thamesvalley-pm
mailing list