2014-01-14 15 views
0

我有我的網站徽標,我希望在上載圖像時將其放到圖像底部。第一步是填充白色背景(高度爲70px),然後將徽標放在左下角。我怎樣才能做到這一點 ? 舉例;將圖像合併到另一個底部

example

回答

0

我解決了。這是解決方案

<?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'); 
相關問題