Navigation Home / Tags / GD

ranking Sort Sort   |   date Sort Sort   |   member Sort Sort

Date Submitted Tue. Mar. 6th, 2007 2:36 PM
Revision 1
Beginner wlasson
Tags "image resize" | GD | images | PHP | Resize
Comments 1 comments
This is a simple function that resizes and image using the GD add on for PHP.
Just a disclaimer: I know its not perfect, but i figured i would post it because the only other one on here is way confusing to some new PHP developers. Hopefully this one will help you learn how to use GD, and then you can write a better one.
Date Submitted Mon. Oct. 23rd, 2006 10:48 PM
Revision 1
Helper jdenton
Tags GD | gif | images | jpeg | PHP | png | Resize
Comments 1 comments
The resize_image function allows you to resize a GIF, JPEG or PNG file to any dimension you wish and put an optional black border around the image. Here's an explanation of the arguements:

$image_path: The complete path to the image to be resized

$max_width: Maximum width of the resized image. Leave 0 if you want to specify only the height and have the width auto-scale.

$max_height: Maximum height of the resized image. Leave 0 if you want to specify only the width and have the height auto-scale.

$file_prefix: This will prepend a string onto the resized image filename. If you want to create a thumbnail image and keep the original, set $file_prefix = 'thumb'.

$dir: Allows you to save the resized image to a sub directory under the $image_path directory. If you want to save thumbnail images to images/thumbs, set $dir = 'thumbs'.

$border: boolean, 1 = border, 0 = no border

$mime: Image mime type. (image/jpeg, image/gif, image/png)