Use GDlib v 2.0 to thumbnail (10)

1 Name: !ozXHloAQRE 2005-04-18 18:11 ID:XHtmQOsK [Del]

I have no ImageMagick, pnmtools or PerlMagick on my host..
I only have GD lib, Have I to write my own thumb code?:°
and, do GD lib works with perl without installing any GD.pm module?
Thanks :)

2 Name: !WAHa.06x36 2005-04-19 05:26 ID:AnkYpp06 [Del]

GBlib needs GD.pm to work in Perl... I've considered adding support for it, but I've yet to see a host that had GD.pm but not ImageMagick, so I haven't bothered. If you do want to try and add it yourself, the thumbnailing code is in wakautils.pl, the make_thumbnail() function.

3 Name: !ozXHloAQRE 2005-04-19 07:46 ID:XHtmQOsK [Del]

thanks, I will try if i ever fix the other problem with my host and if i get them to install GD.pm ... another solution would be change my host :D

4 Post deleted by user.

5 Name: !ozXHloAQRE 2005-04-21 14:39 ID:YSWy88Yp [Del]

I have writed the thumbnail function with GD.pm, if it's useful for someone..
sub make_thumbnail($$$$$;$)
{

my ($filename,$thumbnail,$width,$height,$quality,$convert)=@_;

#Try GD lib
eval 'use GD';
unless(@){
my $src;
my $keys;
if($filename=~/\.jpg$/) {
$src = GD::Image->newFromJpeg($filename);
}
elsif($filename=~/\.png$/) {
$src = GD::Image->newFromPng($filename);
}
else {
system("/absolute/path/to/gif2png", "$filename"); #gif2png taken from futallaby cause i have a GDlib that doesn't support gif
$filename =~ s/\.gif/\.png/;
$src = GD::Image->newFromPng($filename);
}
my ($sW,$sH) = $src->getBounds();
my $key_w = $width / $sW;
my $key_h = $height / $sH;
if ($key_w < $key_h) { $keys = $key_w; }
else { $keys = $key_h; }
my $out_w = int($sW * $keys) +1;
my $out_h = int($sH * $keys) +1;
my $thum = GD::Image->new($out_w,$out_h);
$thum->copyResized($src,0,0,0,0,$out_w,$out_h,$sW,$sH);
my $jpg_data = $thum->jpeg($quality);
open (DISPLAY,">$thumbnail");
binmode DISPLAY;
print DISPLAY $jpg_data;
close DISPLAY;
return 1 unless($!);

}
...

6 Name: !WAHa.06x36 2005-04-21 15:00 ID:AnkYpp06 [Del]

That's nice, and if you don't mind I'll probably steal it and put it into the distro at some point, but: You don't really need to do all that messing around with the sizes. $width and $height are the corrected size of the thumbnail already, and can be used directly.

7 Name: !ozXHloAQRE 2005-04-22 08:27 ID:YSWy88Yp [Del]

aren't they MAX_H and MAX_W? it's even better.. :)
I would be glad if you use it ^^
In GD.pm doc they suggest using copyResampled instead of copyResized but it crashes on my host.. (probably cause of an obsolete lib) but maybe it can be evaluated and inserted if it's available.
Unfortunately copyResized GD thumb <<< ImageMagick thumb :°.

8 Name: !WAHa.06x36 2005-04-22 08:59 ID:ONhaWJCf [Del]

Yeah, Wakaba needs to know what size the thumbnail ends up as so it can put it in the database, and later in the HTML code, so it gets calculated before calling make_thumbnail().

When I stop being distracted by other things and get some work in on a Wakaba update, I'll add the GD code.

9 Post deleted by moderator.

10 Name: Anonymous 2005-10-05 18:09 ID:Heaven [Del]

>>9
I guess its time for a spamfilter update..

Name: Link:
Leave these fields empty (spam trap):
More options...
Verification: