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 :)
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.
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
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($!);
}
...
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.
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 :°.
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.