Quick Search:
 
 PHP Code: Create thumbnails with PHP Jump to:  
Category: >> PHP Code >> Create thumbnails with PHP  

<< lastnext >>

Snippet Name: Create thumbnails with PHP

Description: Simple function that creates thumbnail images using PHP and the GD image library.

Also see:
» GD barchart demo
» Simple image scaling
» Write text onto an image
» Make grayscaled image
» CAPTCHA with GD Image Library

Comment: (none)

Language: PHP
Highlight Mode: PHP
Last Modified: March 16th, 2009

<?PHP
 
FUNCTION thumbnail($image_path,$thumb_path,$image_name,$thumb_width) 
{ 
    $src_img = imagecreatefromjpeg("$image_path/$image_name"); 
    $origw=imagesx($src_img); 
    $origh=imagesy($src_img); 
    $new_w = $thumb_width; 
    $diff=$origw/$new_w; 
    $new_h=$new_w; 
    $dst_img = imagecreate($new_w,$new_h); 
    imagecopyresized($dst_img,$src_img,0,0,0,0,$new_w,$new_h,imagesx($src_img),imagesy($src_img)); 
 
    imagejpeg($dst_img, "$thumb_path/$image_name"); 
    RETURN TRUE; 
} 
 
?>


 
   Home |    Search |    Code Library |    Sponsors |    Privacy |    Terms of Use |    Contact Us © 2003 - 2024 psoug.org