Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Imager module to resize a GIF

Reply
Thread Tools

Imager module to resize a GIF

 
 
Jason C
Guest
Posts: n/a
 
      10-19-2011
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...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?
 
Reply With Quote
 
 
 
 
Jason C
Guest
Posts: n/a
 
      10-20-2011
On Wednesday, October 19, 2011 8:20:50 AM UTC-4, Ben Morrow wrote:
> 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?
 
Reply With Quote
 
 
 
 
Rainer Weikusat
Guest
Posts: n/a
 
      10-20-2011
Jason C <(E-Mail Removed)> writes:

[...]

> 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=...w=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
....).
 
Reply With Quote
 
J. Gleixner
Guest
Posts: n/a
 
      10-20-2011
On 10/20/11 00:47, Jason C wrote:
> On Wednesday, October 19, 2011 8:20:50 AM UTC-4, Ben Morrow wrote:
>> 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, 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Imager module with GIFs jwcarlton Perl Misc 10 02-24-2011 04:42 AM
there are 3-imager video cameras, are there 3-imager still cameras? Bob Fleischer Digital Photography 14 02-07-2010 08:49 PM
Re: filename.gif or filename.gif.jpg? Bergamot HTML 0 05-30-2008 02:56 PM
Re: filename.gif or filename.gif.jpg? Beauregard T. Shagnasty HTML 1 05-30-2008 01:23 PM
How to convert a base 64 encoded GIF image to a *.gif file? hb ASP .Net 6 09-28-2004 08:24 PM



Advertisments