View Single Post
Old 05-18-2008, 10:26 PM   #4 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

Quote:
Originally Posted by Kalle View Post
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($thumbnail255255255);
    
imagefilledrectangle($thumbnail00, (imagesx($thumbnail) - 1), (imagesy($thumbnail) - 1), $bg);

    
imagecopyresampled($thumbnail$source0000$width$heightimagesx($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
Orc is offline  
Reply With Quote