Resizing an Image Using PHP


/ Published in: PHP
Save to your folder(s)

To use the resize function you must pass in the forced width, forced height, source image, and destination image. The function then uses the GD2 library functions to read the source image's size. It will then calculate the new image's size based off of the forced width and height. This function will maintain the original image's aspect ratio so your image won't look distorted. It won't change the source image at all but when the function is done running you will end up with the destination image which is resized to the dimensions you passed into the function. As far as I know, this function requires the GD2 library although you might be able to get it to work with the GD1 library. The GD library extension must be enabled in PHP before you can use GD2 functions so keep that in mind as well. You can use the PHP function phpinfo() to see if GD2 is enabled or to see what version of the GD library your server is using.

URL: http://www.netlobo.com/php_image_resize_gd2.html#

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.