note 53031 deleted from function.imagecopyresampled by cmb

From: Date: Sun, 19 May 2019 16:09:14 +0000
Subject: note 53031 deleted from function.imagecopyresampled by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-211074@lists.php.net to get a copy of this message
Note Submitter: fluffle <at> gmail <dot> com ---- Just to clarify that src_w and src_h do not necessarily need to be the source image width and height, as they specify the size of the rectangle cropped from the source picture, with its top left corner situated at (src_x, src_y). For example, the code below crops a jpeg image to be square, with the square situated in the centre of the original image, and then resizes it to a 100x100 thumbnail. list($ow, $oh) = getimagesize($image_filename); $big = imagecreatefromjpeg($image_filename); $thumb = imagecreatetruecolor(100,100); if ($ow > $oh) { $off_w = ($ow-$oh)/2; $off_h = 0; $ow = $oh; } elseif ($oh > $ow) { $off_w = 0; $off_h = ($oh-$ow)/2; $oh = $ow; } else { $off_w = 0; $off_h = 0; } imagecopyresampled($thumb, $big, 0, 0, $off_w, $off_h, 100, 100, $ow, $oh);

« previous php.notes (#211074) next »