【发布时间】:2014-01-14 13:56:05
【问题描述】:
我有我网站的徽标,我想在上传时将其放在图片底部。第一步是填充白色背景(高度为 70 像素),然后将徽标放在左下角。我怎样才能做到这一点 ? 例如;
【问题讨论】:
我有我网站的徽标,我想在上传时将其放在图片底部。第一步是填充白色背景(高度为 70 像素),然后将徽标放在左下角。我怎样才能做到这一点 ? 例如;
【问题讨论】:
我解决了。这是解决方案
<?php
function merge($filename_x, $filename_y, $filename_result) {
list($width_x, $height_x) = getimagesize($filename_x);
list($width_y, $height_y) = getimagesize($filename_y);
$image = imagecreatetruecolor($width_x, $height_y + $height_x);
$image_x = imagecreatefromjpeg($filename_x);
$image_y = imagecreatefrompng($filename_y);
$white = imagecolorallocate($image, 255, 255, 255);
imagefill($image, 0, 0, $white);
imagecopy($image, $image_x, 0, 0, 0, 0, $width_x, $height_x);
imagecopy($image, $image_y, 0, $height_x, 0, 0, $width_y, $height_y);
imagejpeg($image, $filename_result);
imagedestroy($image);
imagedestroy($image_x);
imagedestroy($image_y);
}
merge('image.jpg', 'simge.png', 'merged.jpg');
【讨论】: