note 62692 deleted from function.imagecopyresampled by cmb
| From: | cmb@php.net | Date: | Sun, 19 May 2019 16:13:02 +0000 |
| Subject: | note 62692 deleted from function.imagecopyresampled by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-211082@lists.php.net to get a copy of this message | ||
Note Submitter: dmitry at dest dot by
----
Simple script on change of width and automatic creation of height, and also creation of the
signature in the right we string to a corner. (Only for Jpg)
function easyResize($img_sourse, $save_to, $quality, $width, $str) {
$size = GetImageSize($img_sourse);
$im_in = ImageCreateFromJPEG($img_sourse);
$new_height = ($width * $size[1]) / $size[0]; // Generate new height for image
$im_out = imagecreatetruecolor($width, $new_height);
ImageCopyResampled($im_out, $im_in, 0, 0, 0, 0, $width, $new_height, $size[0], $size[1]);
#Find X & Y for note
$X_var = ImageSX($im_out);
$X_var = $X_var - 130;
$Y_var = ImageSY($im_out);
$Y_var = $Y_var - 25;
#Color
$white = ImageColorAllocate($im_out, 0, 0, 0);
#Add note(simple: site address)
ImageString($im_out,2,$X_var,$Y_var,$str,$white);
ImageJPEG($im_out, $save_to, $quality); // Create image
ImageDestroy($im_in);
ImageDestroy($im_out);
}
// $str - Inscription on the image;