note 66054 deleted from function.imagecopyresampled by cmb

From: Date: Wed, 12 Oct 2016 15:50:56 +0000
Subject: note 66054 deleted from function.imagecopyresampled by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-206861@lists.php.net to get a copy of this message
Note Submitter: spencejames2000 at yahoo dot co dot uk ---- For anyone suffering from the srcX and srcY bug (some versions of gd ignore them completely - see http://bugs.php.net/bug.php?id=12780 for details), a quick solution is to use this code snippet: <?php function imgcopyresampled(&$dst_img, $src_img, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h) { $tmp_img = imagecreatetruecolor($src_w, $src_h); $rv2 = imagecopy($tmp_img, $src_img, 0,0, $src_x, $src_y, $src_w, $src_h); $rv1 = imagecopyresampled($dst_img, $tmp_img, $dst_x,$dst_y, 0,0, $dst_w, $dst_h, $src_w, $src_h); imagedestroy($tmp_img); return($rv1 and $rv2); } ?> By using imagecopy to extract the relevant portion of the source image, it works a lot more quickly than pike's solution below, and also without the extra blur. It may be useful to use override_function in existing projects, although I have not tested this myself.

« previous php.notes (#206861) next »