Thumbnail Creator

<?php function createThumbnail($image, $new_width, $new_height, $thumbname){ $pic = imagecreatefrompng($image); $thumb = imagecreatetruecolor($new_width, $new_height); imagecopyresampled($thumb, $pic, 0, 0, 0, 0, $new_width, $new_height, imagesx($pic), imagesy($pic)); imagepng($thumb, $thumbname); imagedestroy($thumb); imagedestroy($pic); } ?>

This function can be used to create thumbnails from other images.
(Does only work with PNG images)

$image = The image you want to create a thumbnail from.
$new_width = The width of the new thumbnail.
$new_height = The height of the new thumbnail.
$thumbname = the name of the new thumbnail.

Sample:

<?php function createThumbnail($image, $new_width, $new_height, $thumbname){ $pic = imagecreatefrompng($image); $thumb = imagecreatetruecolor($new_width, $new_height); imagecopyresampled($thumb, $pic, 0, 0, 0, 0, $new_width, $new_height, imagesx($pic), imagesy($pic)); imagepng($thumb, $thumbname); imagedestroy($thumb); imagedestroy($pic); } createThumbnail("myimage.png", 520, 400, "lol.png"); ?>

This will create a new image called lol.png

Digg This

Need a reliable webhost? Take my word for it and go with Hostgator Green Web Hosting by HostGator