How to detect an image type with GD

Hi.

I want to load an image with GD, but I must know which type is each one
in order to:
my $srcimage = GD::Image->newFromGif("foo.gif");
my $srcimage = GD::Image->newFromJpeg("foo.jpg");
....

How can I detect it? Thank you very much.
Francesco Moi [ Mi, 08 November 2006 18:10 ] [ ID #1528950 ]

Re: How to detect an image type with GD

"Francesco Moi" <francescomoi [at] usa.com> wrote:

> Hi.
>
> I want to load an image with GD, but I must know which type is each one
> in order to:
> my $srcimage = GD::Image->newFromGif("foo.gif");
> my $srcimage = GD::Image->newFromJpeg("foo.jpg");
> ...
>
> How can I detect it? Thank you very much.

With magic: http://search.cpan.org/search?query=magic&mode=all

--
John Experienced Perl programmer: http://castleamber.com/

Perl help, tutorials, and examples: http://johnbokma.com/perl/
John Bokma [ Mi, 08 November 2006 21:03 ] [ ID #1528951 ]

Re: How to detect an image type with GD

[A complimentary Cc of this posting was sent to
Francesco Moi
<francescomoi [at] usa.com>], who wrote in article <1163005823.701417.13950 [at] b28g2000cwb.googlegroups.com>:
> Hi.
>
> I want to load an image with GD, but I must know which type is each one
> in order to:
> my $srcimage = GD::Image->newFromGif("foo.gif");
> my $srcimage = GD::Image->newFromJpeg("foo.jpg");
> ...
>
> How can I detect it?

Do not. Let GD detect it.

Hope this helps,
Ilya
Ilya Zakharevich [ Mi, 08 November 2006 21:22 ] [ ID #1528952 ]
Perl » comp.lang.perl.modules » How to detect an image type with GD

Vorheriges Thema: Any ImageMagick Gurus out there? I need HELP!
Nächstes Thema: Failure to build Math::Pari Solaris 10 Studio 11