Re-sizing image by width using php

A simple yet very useful function to re-size image by maximum width while keeping width and height in proportion. You just need to pass the maximum width allowed to this function and this function will return you an array containing new width and height.

For example, resize_image_by_width(“/var/www/mysite/images/imagename.jpg”, 200) would return array(‘w’=>200, ‘h’=>62.8787878788) to a 264×83 image.

Note: Pass full absolute path to image as the first argument.

Leave a Reply

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