Php 将图像合并到另一个';水底

Php 将图像合并到另一个';水底,php,image,merge,Php,Image,Merge,我有我的网站的标志,我想把它放在图片底部,当我上传它。第一步是填充白色背景(高度为70px),然后将徽标置于左下角。我该怎么做? 比如, 我解决了。这就是解决办法 <?php function merge($filename_x, $filename_y, $filename_result) { list($width_x, $height_x) = getimagesize($filename_x); list($width_y, $height_y) = getima

我有我的网站的标志,我想把它放在图片底部,当我上传它。第一步是填充白色背景(高度为70px),然后将徽标置于左下角。我该怎么做? 比如,


我解决了。这就是解决办法

<?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');