【问题标题】:PHP Image Merge with Photo Frame [duplicate]PHP图像与相框合并[重复]
【发布时间】:2011-11-08 03:45:04
【问题描述】:

可能重复:
How can I merge 3 images into 1 image via PHP?

如何将相框和照片合并到相框上的特定位置?我有以下代码,但它很奇怪,以至于照片必须与框架一样大才能合并它们。除了我所做的任何解决方案或错误吗?非常感谢所有回复。

$image = imagecreatefromjpeg($me);

$frame = imagecreatefrompng('HorizontalFrame.png');



imagealphablending($frame, true);

imagesavealpha($frame, true);

imagecopy($image, $frame, 0, 0, 0, 0, 325, 276);

imagepng($image, 'image_4.png');

【问题讨论】:

标签: php gd


【解决方案1】:

我找到了更好理解的正确方法:

$images = array( $_GET['color'], $_GET['face'], $_GET['hat'] );

    // Allocate new image
    $img = imagecreatetruecolor(58, 75);
    // Make alpha channels work
    imagealphablending($img, true);
    imagesavealpha($img, true);

    foreach($images as $fn) {
        // Load image
        $cur = imagecreatefrompng($fn);
        imagealphablending($cur, true);
        imagesavealpha($cur, true);

        // Copy over image
        imagecopy($img, $cur, 0, 0, 0, 0, 58, 75);

        // Free memory
        imagedestroy($cur);
    }   

    header('Content-Type: image/png');  // Comment out this line to see PHP errors
    imagepng($img);

归功于:DMin via How can I merge 3 images into 1 image via PHP?

【讨论】:

    【解决方案2】:

    我使用 CSS:

    • 只需为 HTML 提供一个 ID(例如字符、头发、武器)
    • 然后使用 value: absolute 并将其映射到特定的 x 和 y 轴上。

    图像 a 将与图像 b 重叠

    如果您使用 PNG,那么您可以设置不可见的 NH,这使它更像是一个更酷的一个

    【讨论】:

      猜你喜欢
      • 2011-10-18
      • 2011-07-28
      • 1970-01-01
      • 2012-08-14
      • 2019-03-12
      • 1970-01-01
      • 2012-08-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多