将图像放在另一个图像的左下角

时间:2011-05-07 21:28:19

标签: php image gd

所以,我有这个代码将图像放在图像的最右边。

现在我想完全这样做,但是在左下角。只是不能让电线正确。有什么帮助吗?

<?php

    $main_img   = "image_path"; 
    $logoimage  = "logo_path"; 
    $padding    = 0; 
    $opacity    = 100;
    $logo       = imagecreatefromjpeg($logoimage);
    $image      = imagecreatefromjpeg($main_img);
    $logosize   = getimagesize($logoimage);
    $logowidth  = $logosize[0];  
    $logoheight = $logosize[1];  
    $image_size = getimagesize($main_img);  
    $dest_x     = $image_size[0] - $logowidth - $padding; 
    $dest_y     = $image_size[1] - $logoheight - $padding;
    imagecopymerge($image, $logo, $dest_x, $dest_y, 0, 0, $logowidth, $logoheight, $opacity);

?>

1 个答案:

答案 0 :(得分:4)

更改此行:

$dest_x = $image_size[0] - $logowidth - $padding; 

对此:

$dest_x = $padding;