Well I'm not so sure the problem is related to the module or to the library. The problem is as such:
I've created a program that creates thumbnails to jpeg and png files in a certain directory.
When trying to use the newFromJpeg subroutine in my program (Running on my site's FreeBSD server, on my computer it works fine), I get an error that libgd was not built with jpeg support. Well, probably libgd was not build with jpeg support. Only that the server's administrator assured me that jpeg support was installed and even reinstalled it to make sure.
Now the thing is that at first I didn't know the GD module was installed in the server and uploaded it myself (and used lib on the directory to which I uploaded). I've tried some times and got some error messages (Until I realised it was installed). At a certain point, when checking the picture directory, I noticed that thumbnails for jpeg files where actually created. So libgd must have been installed with jpeg support. The administrator claims the GD Module's version is 2.07 (Latest). Anyone has an idea what might cause this?

Here's the program in case it helps:
#!/usr/bin/perl -w BEGIN { $|=1; print "Content-type: text/html\n\n"; use CGI::Carp('fatalsToBrowser'); } use lib "/path-to-perl-modules"; use GD; use CGI; use strict; my $directory = "/path-to-pics"; my $thumbdir = "/path-to-pics/thumbs"; my $url = "http://www.www.com/cgi-bin"; my @dirs = getdirs($directory); for my $dir (@dirs) { update($dir); } print "Thumbnails created/updated successfully"; sub getdirs { my $directory = shift; my @dirs; opendir (DIR, $directory); my @files = grep { !/^\.\.?$/ } readdir DIR; closedir DIR; push (@dirs, $directory); for my $file (@files) { if (-d "$directory/$file") { getdirs("$directory/$file"); } } return @dirs; } sub update { my ($directory) = shift; my ($image, $desimage); opendir (DIR, $directory); my @files = grep { !/^\.\.?$/ } readdir DIR; closedir DIR; for my $file (@files) { my $full = "$directory/$file"; if (-f $full && $full =~ m/\.(png|jpg)/i) { my $extension = $1; open (PNG, "$full") || die; if ($extension eq "png") { $image = newFromPng GD::Image(\*PNG) || die; } else { $image = newFromJpeg GD::Image(\*PNG) || die; } close PNG; my ($width,$height) = $image->getBounds(); if ($width <= 250 && $height <= 250) { # DO NOTHING } else { if ($width <= 250 && $height > 250) { my $percent = (250*100)/$height; my $newidth = ($width*$percent)/100; $desimage = new GD::Image($newidth, 250); $desimage->copyResized($image, 0, 0, 0, 0, $newidth, 250, $w +idth, $height); } elsif ($width > 250 && $height <= 250) { my $percent = (250*100)/$width; my $newheight = ($height*$percent)/100; $desimage = new GD::Image(250, $newheight); $desimage->copyResized($image, 0, 0, 0, 0, 250, $newheight, +$width, $height); } else { if ($width > $height) { my $percent = (250*100)/$width; my $newheight = ($height*$percent)/100; $desimage = new GD::Image(250, $newheight); $desimage->copyResized($image, 0, 0, 0, 0, 250, $newheight +, $width, $height); } else { my $percent = (250*100)/$height; my $newidth = ($width*$percent)/100; $desimage = new GD::Image($newidth, 250); $desimage->copyResized($image, 0, 0, 0, 0, $newidth, 250, +$width, $height); } } $file =~ m/^(.+)\.\w+$/; my $new = "${file}.png"; open (FILE, "+>$thumbdir/$new") or die "Can't open file: $!"; binmode FILE; print FILE $desimage->png; close FILE; } } } }


-------------------------
Live fat, die young

edited by ybiC: balanced <readmore> tags


In reply to Problem with the GD module by ido50

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.