[magick-users] Generate 'png' from Blob
Bill Moseley
moseley at hank.org
Tue Feb 12 12:50:33 PST 2008
Can anyone offer help with this?
On Sat, Feb 09, 2008 at 07:09:40AM -0800, Bill Moseley wrote:
> I'm using the Perl interface.
>
>
> I have a file, and I'm not sure of its contents. I want
> to read it into memory (if it's a supported ImageMagic format),
> resize it, and then write it to a database as a png image. So even if
> its a PDF it will end up as a png.
>
> The very basic part I'm missing is how to convert to png.
>
> So, excluding the error checking, I'm basically doing:
>
> $magick = Image::Magick->new;
> $magick->Read( $filename );
>
> $image = $magick->[0];
> $image ->Resize( '100x100' );
> $image->Strip;
>
> $blob = $image->ImageToBlob;
> $mime = $image->mime;
>
> The docs say ImageToBlob takes any "Attribute" and I tried
>
> $blob = $image->ImageToBlob( magick => 'png' );
>
>
>
>
> My second question is can I trust the Read() method to
> fail on bad data? My only other option would be to use file -i or
> some MIME magic method to try and guess the file's MIME type -- but
> still then I don't know if that would be acceptable to ImageMagic.
>
>
> Thanks,
>
>
>
>
> --
> Bill Moseley
> moseley at hank.org
>
> _______________________________________________
> Magick-users mailing list
> Magick-users at imagemagick.org
> http://studio.imagemagick.org/mailman/listinfo/magick-users
>
--
Bill Moseley
moseley at hank.org
More information about the Magick-users
mailing list