How to resize an image

In this post, we will discuss about how to resize an image using PHP. The code can be used to prepare avatar of a website users photo for their accounts logo. The suitable place of the code is immediate after the image is uploaded. so, I suggest you to have a look at my one of previous post “how to upload an image” if you are not feeling comfort with uploading an image.

I have prepared a function containing the required code for resizing of uploaded image. that function is used in combination with upload an image functionality.

you can simply call this function by providing uploaded image path (with filename) and required file size (image width, image height). The function will work using image sampling technique and you will get required sized image.

you can use the code in combination with image upload functionality.

the download able working example has complete functionality of resizing of image after uploading it.

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.