note 24975 rejected from function.imagecopyresized by jmcastagnetto
| From: | jmcastagnetto@php.net | Date: | Fri, 06 Sep 2002 22:54:31 +0000 |
| Subject: | note 24975 rejected from function.imagecopyresized by jmcastagnetto | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-36276@lists.php.net to get a copy of this message | ||
i Use en external file to dynamically generate thumbs
--------------------------------
<?php
$size = 200;
$margin = 2;
$jpegdir = 'photo';
$jpeg = $jpegdir .'/'. $HTTP_GET_VARS['img'];
$size2 = $HTTP_GET_VARS['newheight'];
if($d=getimagesize($jpeg)){
$dim = ($d[1]>$d[0]) ? 1 : 0;
$mod = $size / $d[$dim];
$w = (int) ($d[0] * $mod);
$h = (int) ($d[1] * $mod);
$x = (int)(($size + $margin - $w) / 2);
$y = (int)(($size2 + $margin - $h) / 2);
header('Content-type: image/jpeg');
$src = imagecreatefromjpeg($jpeg);
$dst = imagecreate($size+($margin * 2), $size2+($margin * 2));
$white = imagecolorallocate($dst,0,0,0);
imagefill($dst,0,0,$black);
imagecopyresized($dst,$src,0,0,0,0,$size+5,$size2+5,$d[0],$d[1]);
imagejpeg($dst);
imagedestroy($dst);
imagedestroy($src);
}
?>
------------------------
now the thumbs are available by:
<img src=thumb.php?img=$filename&newheight=$newheight>
it works cool - i dont care about thumb quality... i need speed
my server is amd k62-400 with 64MB of ram and this script is very slow on that machine.. is there
any possibility to speed it up? maybe there is a faster, (even less accurate) method to resize the
image using GD ?
Krynix