note 106539 added to function.imagecopyresized

From: Date: Thu, 17 Nov 2011 11:09:40 +0000
Subject: note 106539 added to function.imagecopyresized
Groups: php.notes 
Request: Send a blank email to php-notes+get-184540@lists.php.net to get a copy of this message
I couldn't find any script that resize an image and give border to it. So I made one myself. Hope that can help you. <?php function imagecopyresizedwithborder(&$src,$width,$height,$borderthickess,$bordercolor=NULL) { list($width_orig, $height_orig) = array(imagesx($src),imagesy($src)); if ($width && ($width_orig < $height_orig)) { $width = ($height / $height_orig) * $width_orig; } else { $height = ($width / $width_orig) * $height_orig; } $dst = imagecreatetruecolor($width+2*$borderthickess,$height+2*$borderthickess); imagecolortransparent($dst,imagecolorallocate($dst,0,0,0)); imagealphablending($dst,false); imagesavealpha($dst,true); imagefill($dst,0,0,(isset($bordercolor) ? $bordercolor : imagecolorallocate($dst,255,255,255))); imagecopyresampled($dst,$src,$borderthickess,$borderthickess,0,0,$width,$height,imagesx($src),imagesy($src)); return $dst; } ?> ---- Server IP: 180.92.182.81 Probable Submitter: 121.203.17.21 ---- Manual Page -- http://www.php.net/manual/en/function.imagecopyresized.php Edit -- https://master.php.net/note/edit/106539 Del: integrated -- https://master.php.net/note/delete/106539/integrated Del: useless -- https://master.php.net/note/delete/106539/useless Del: bad code -- https://master.php.net/note/delete/106539/bad+code Del: spam -- https://master.php.net/note/delete/106539/spam Del: non-english -- https://master.php.net/note/delete/106539/non-english Del: in docs -- https://master.php.net/note/delete/106539/in+docs Del: other reasons-- https://master.php.net/note/delete/106539 Reject -- https://master.php.net/note/reject/106539 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#184540) next »