Imager module to resize a GIF

J

Jason C

I have a web script that resizes images uploaded by the site visitor to predetermined dimensions. This works fine for JPG and PNG, but not for GIF.

I've just about copied the script verbatim from CPAN for testing, but getwidth(), etc, all return nothing:

#!/usr/bin/perl
#
use CGI::Carp qw(fatalsToBrowser);
use Imager;
use strict;
use warnings;

my $img = Imager->new();
$img->open(file=>'/home/myacct/www/myimage.gif', type=>'gif')
or die "not read";

print "Content-type: text/html\n\n";

if (-e "/home/myacct/www/myimage.gif") {
print "Image information:\n";
print " Width: ". $img->getwidth() ."\n";
print " Height: ". $img->getheight() ."\n";
print " Type: ". $img->type() ."\n";
}

else { print "not found"; }
exit;

http://search.cpan.org/~tonyc/Imager-0.85/lib/Imager/ImageTypes.pod

It prints "Image information", etc, so the image is found... it's just not being read.

I do have giflib installed on the server. I wasn't sure if I installed it before or after Imager, though, so I uninstalled Imager and reinstalled it, but that had no impact.

If any of you are familiar with Imager, is there something else that I need to do in order to get it to recognize GIF files?
 
J

Jason C

What you have there works for me, here. Do you, in fact, have a .pm and
a .so for Imager::File::GIF? If you run ldd against the .so (which
should be somewhere like /usr/local/lib/perl5/site_perl/5.12.4/
amd64-freebsd/auto/Imager/File/GIF/GIF.so) are all the libraries it
needs found?

Is there something wrong with your gif file? There is a file called
GIF/testimg/expected.gif in the Imager distribution; since that's the
file Imager uses to make sure giflib works, you could try that (it
should be 16x16px).

Ben

You're right, it's more likely that there's something missing on the server.. I thought that the Imager package would include everything it needed, butI guess not.

I don't see Imager::File::GIF in my list of installed modules (from WHM/cPanel), so I tried to install it manually. The install failed with:

perl-64bit-hack: enabled
GIF: building independently
GIF: main: includes not found - libraries not found
GIF: Checking if the compiler can find them on its own
GIF: Test code failed: Can't link/include 'gif_lib.h', 'stdio.h', 'gif'
OS unsupported: GIF libraries or headers not found
No 'Makefile' created TONYC/Imager-File-GIF-0.81.tar.gz
/usr/local/cpanel/scripts/cpan_sandbox/x86_64/perl Makefile.PL OTHERLDFLAGS=-L/usr/lib64 LDFLAGS=-L/usr/lib64 EXTRALIBDIR=/usr/lib64 -- NOT OK
Running make install
Make had some problems, won't install
Could not read metadata file. Falling back to other methods to determine prerequisites
perlmod--Install done


I also tried to install it via SSH, like so:

perl -MCPAN -e shell;
install Imager::File::GIF

And received the same error. I even tried:

force install Imager::File::GIF

With the same result.

Interestingly, my modules go to /usr/lib/perl5/site_perl/5.8.8, but I don'tsee Imager installed there at all! And I definitely don't have Imager/File/GIF. Imager is working, though, so it exists somewhere... I just don't know where. Could this be why it's failing?
 
R

Rainer Weikusat

[...]
I don't see Imager::File::GIF in my list of installed modules (from WHM/cPanel), so I tried to install it manually. The install failed with:

perl-64bit-hack: enabled
GIF: building independently
GIF: main: includes not found - libraries not found
GIF: Checking if the compiler can find them on its own
GIF: Test code failed: Can't link/include 'gif_lib.h', 'stdio.h',
'gif'

According to

http://www.google.com/#hl=en&sugexp....,cf.osb&fp=b24facda13a68307&biw=1537&bih=858

this should mean that you're either missing the giflib library,

http://giflib.sourceforge.net

or (if you are using a package provided by some Linux distribution)
the corresponding 'development' package which would usually include
the headers (since disks are so tiny nowadays and just keep shrinking
and shrinking, Linux distributors have commonly chosen that the
overhead of having a bunch of possibly unused text files installed
would be too much for 'end users' to bear, given that only relatively
few of them will likely ever compile something on their computers
....).
 
J

J. Gleixner

You're right, it's more likely that there's something missing on the server. I thought that the Imager package would include everything it needed, but I guess not.

I don't see Imager::File::GIF in my list of installed modules (from WHM/cPanel), so I tried to install it manually. The install failed with:

perl-64bit-hack: enabled
GIF: building independently
GIF: main: includes not found - libraries not found ^^^^^^^^^^^^^^^^^^^
GIF: Checking if the compiler can find them on its own
GIF: Test code failed: Can't link/include 'gif_lib.h', 'stdio.h', 'gif'
OS unsupported: GIF libraries or headers not found

[...]

You probably need to have the various gif, jpeg, etc. libraries
installed, or possibly modify your Include path. See the README
file, which is part of the distribution, or you can view it online:
http://cpansearch.perl.org/src/TONYC/Imager-0.85/README
Interestingly, my modules go to /usr/lib/perl5/site_perl/5.8.8, but I don't see Imager installed there at all! And I definitely don't have Imager/File/GIF. Imager is working, though, so it exists somewhere... I just don't know where. Could this be why it's failing?

To see where the module is located, try: perldoc -l Imager
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top