05-18-2008, 10:26 PM
|
#4 (permalink)
|
|
The Prestige
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
|
Quote:
Originally Posted by Kalle
I did a quick thumbnail function here to show you how simple it really is, it might not be working as im pretty tired and I was about to go to bed ;)
PHP Code:
<?php
/** Assuming $source is an image resource to the image we need to alter */
/** Max width + height */
$width = 100;
$height = 100;
$factor = 1;
if(imagesx($source) > $width)
{
$factor = ($width / imagesx($source));
}
if((imagesy($source * $factor) > $height)
{
$factor = ($height / imagesy($source));
}
$width = floor(imagesx($source) * $factor);
$height = floor(imagesy($source) * $factor);
$thumbnail = imagecreatefromtruecolor($width, $height);
$bg = imagecolorallocate($thumbnail, 255, 255, 255);
imagefilledrectangle($thumbnail, 0, 0, (imagesx($thumbnail) - 1), (imagesy($thumbnail) - 1), $bg);
imagecopyresampled($thumbnail, $source, 0, 0, 0, 0, $width, $height, imagesx($source), imagesy($source));
imagedestroy($source);
$source = NULL;
/** $thumbnail is now the generated thumbnail */
?>
|
Didn't work at all :P
__________________
VillageIdiot can have my babbies ;d
|
|
|
|