public marks

PUBLIC MARKS from imelgrat with tag "map image"

19 July 2007 04:30

Resize image proportionally with optional background color using PHP and GD

(via)
This is an update of a previous post, which described a PHP function for resizing images using the GD library and some clever math calculations to determine the optimal width and height. This function resizes a picture to the chosen size while maintaining the original image’s proportions, thus avoiding image distortion. In the previous version, the function always used a black background, so images that needed to be cropped would sometimes display black bars on the sides. This updated function allows the user to select the background color, passed as an array of 3 integer numbers (RED, GREEN, BLUE). This makes it eay to “blend” the resized images to the page background, without any black bars on the sides. This new version has been fully documented (using PHPDoc-style comments).

imelgrat's TAGS related to tag "map image"

function +   image +   image library +   image optimization +   image optimize +   image reduce +   image resize +   jpeg images +   php +   php function +   Sample Code +