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

Hi fellow monks! I just started to use GD.pm. I wrote this little script to check a GIF's dimensions
#!/usr/bin/perl use strict; use warnings; use GD; use File::Find; my $file= shift; open(my $imgFile, '<', $file ) or die "Can't read $file: $!\n"; binmode $imgFile; my $img= newFromGif GD::Image( $imgFile ); close($imgFile); die "Didn't work" unless defined $img; my ($w, $h)= $img->getBounds(); print $file,": ",$w," x ",$h,"\n";

Unfortunately it fails. Replacing Gif with Png for a png image works fine.

Gif is said to be supported:
gdlib-config --features
GD_XPM GD_JPEG GD_FONTCONFIG GD_FREETYPE GD_PNG GD_GIF
What else can I check to find out what's going wrong here?

Update: Should anyone else stumble across this: I was using gd2 from fink and also gd-pm586 from there. Now I removed gd-pm586 and made my own from CPAN source and it worked!


s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
+.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e

Replies are listed 'Best First'.
Re: Solved: GD.pm fails with GIF
by dws (Chancellor) on Apr 08, 2006 at 00:16 UTC
    Image::Size does what you're looking for, without requiring GD.

      Thanks for the info. But getting the size is only the first step. My script (which is done now) slices too big images and rotates all 90 degrees clockwise.

      BTW: "Image" was actually my first try insteasd of GD, but I failed miserably :-(. I had so many errors and missing prerequists...

      Then I saw that there was a fink-package for GD and gave it a try.


      s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
      +.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e