Using thumbnails with just PHP GD (4)

1 Name: Grz : 2008-06-20 14:12 ID:5IWl+dvt [Del]

Hello,

i have created a little extension because i don't have any perl modules for images generating on my host so i use GD in PHP, i think it can be usefull for peoples who have just basics perls modules.

Here is the script to put in "make_thumbnail" function in the file "wakautils.pl":

system("php -f makethumb.php $filename $thumbnail $width $height $quality $convert");
return 1;

And here the PHP script (called makethumb.php here):

<?php

if($argc == "7")
{
if(substr($argv[1],-3) == "png")
{
header ("Content-type: image/png");
$image = imagecreatefrompng($argv[1]);
}
else if(substr($argv[1],-3) == "gif")
{
header ("Content-type: image/gif");
$image = imagecreatefromgif($argv[1]);
}
else
{
header ("Content-type: image/jpeg");
$image = imagecreatefromjpeg($argv[1]);
}
$dst = imagecreatetruecolor(intval($argv[3]), intval($argv[4]));

$wsrc = imagesx($image);
$hsrc = imagesy($image);
$wdst = imagesx($dst);
$hdst = imagesy($dst);
imagecopyresampled($dst, $image, 0, 0, 0, 0, $wdst, $hdst, $wsrc, $hsrc);
imagejpeg($dst,$argv[2],intval($argv[5]));
imagedestroy($image);
imagedestroy($dst);
}

?>

I hope it will be usefull. :)

2 Name: Anonymous : 2008-06-21 01:38 ID:Heaven [Del]

doesn't wakaba use the convert utility by default and only fall back to using perl modules if it can't find it?
i'd think it'd be better to compile it for whatever platform your web server is running on and then upload that binary and set CONVERT_COMMAND in config.pl...

3 Name: Grz : 2008-06-21 20:01 ID:BN5gGxSo [Del]

i dunno, i have tried all convert thumbnails stuff but doesn't work... because it seem to use only PERL module... mine use PHP, and also i don't have a full access to my server so i can't install any stuff.

4 Name: Anonymous : 2008-06-23 18:52 ID:Heaven [Del]

>>3 by default, wakaba tries to use imagemagick's convert command, which is independent of perl.

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