0

我想将图像的水印对齐到右侧。

这是我到目前为止所拥有的,但它与左侧对齐......

// Add Watermark featuring Website Name
$home_url = home_url();
$search = array('http://','https://');
$site_name = str_ireplace($search, '', $home_url);
$watermark = imagecreatetruecolor($width, $height+15);

// Determine color of watermark's background
if (is_array($Meme_Generator_Data) && 
    array_key_exists('watermark_background',$Meme_Generator_Data) && 
    strlen($Meme_Generator_Data['watermark_background']) == 7) 
{
    $wm_bg = $this->convert_color(substr($Meme_Generator_Data['watermark_background'], 1));
    $bg_color = imagecolorallocate($watermark, $wm_bg[0], $wm_bg[1], $wm_bg[2]);
    imagefill($watermark, 0, 0, $bg_color);
}

// Determine color of watermark's text
if (is_array($Meme_Generator_Data) && 
    array_key_exists('watermark_text',$Meme_Generator_Data) && 
    strlen($Meme_Generator_Data['watermark_text']) == 7) 
{
    $wm_text = $this->convert_color(substr($Meme_Generator_Data['watermark_text'], 1));
    $text_color = imagecolorallocate($watermark, $wm_text[0], $wm_text[1], $wm_text[2]);
} else {
    $text_color = imagecolorallocate($watermark, 255, 255, 255);
}

imagestring($watermark, 5, 5, $height, $site_name, $text_color);                    
imagecopy($watermark, $img, 0, 0, 0, 0, $width, $height);
$img = $watermark;
4

1 回答 1

0

代替

imagecopy($watermark, $img, 0, 0, 0, 0, $width, $height);

imagecopy($watermark, $img, imagesx($img) - $width, 0, 0, 0, $width, $height);
于 2013-09-01T05:38:16.677 回答