note 123343 added to function.imagecopyresampled
| From: | aykuty at gmail dot com | Date: | Wed, 14 Nov 2018 08:21:54 +0000 |
| Subject: | note 123343 added to function.imagecopyresampled | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-209710@lists.php.net to get a copy of this message | ||
scale image with ratio and then completes to the canvas size by centering
<?php
/*
verilen maksimum deÄerlere göre resmi boyutlandırır ve beyaz renk ile cerceveye ortalar.
trendyol entegrasyonu için yazmıÅtım.
Aykut YILDIZGÃRÃR
aykuty add gmail dot com
*/
function set_image2canvas($file, $new_file, $canvas_width=1200, $canvas_height =1800, $quality=100)
{
if (!file_exists( $new_file )) {
list($width, $height, $type, $attr) = getimagesize( $file );
if($width> $height) {
$width_tt=$canvas_width;
$height_tt=round($height/$width*$canvas_width);
$off_y = ceil(( $canvas_height - $height_tt)/2);
$off_x=0;
} else {
$height_tt=$canvas_height;
$width_tt=round($width/$height*$canvas_height);
$off_x=ceil(($canvas_width - $width_tt)/2);
$off_y=0;
}
$thumb=imagecreatefromjpeg( $file );
$thumb_p = imagecreatetruecolor($canvas_width, $canvas_height);
$bg = imagecolorallocate ( $thumb_p, 255, 255, 255 );
imagefill ( $thumb_p, 0, 0, $bg );
imagecopyresampled($thumb_p, $thumb, $off_x, $off_y, 0, 0, $width_tt, $height_tt, $width,
$height);
imagejpeg($thumb_p,$new_file,$quality);
}else{ //hedef resim zaten var
return -1;
}
}
?>
----
Server IP: 208.43.231.9
Probable Submitter: 82.222.245.78
----
Manual Page -- http://php.net/manual/en/function.imagecopyresampled.php
Edit -- https://master.php.net/note/edit/123343
Del: integrated -- https://master.php.net/note/delete/123343/integrated
Del: useless -- https://master.php.net/note/delete/123343/useless
Del: bad code -- https://master.php.net/note/delete/123343/bad+code
Del: spam -- https://master.php.net/note/delete/123343/spam
Del: non-english -- https://master.php.net/note/delete/123343/non-english
Del: in docs -- https://master.php.net/note/delete/123343/in+docs
Del: other reasons-- https://master.php.net/note/delete/123343
Reject -- https://master.php.net/note/reject/123343
Search -- https://master.php.net/manage/user-notes.php