dongsu1539
dongsu1539
2010-08-25 11:59

如何使用imagemagick创建水印

  • php
  • overlay
  • imagemagick
已采纳

I'm trying to create a watermark with ImageMagick however, the guides on layering are pretty daunting. Basically I'll have one base image say "base.jgp" and an overlay image say "overlay.jpg". Overlay.jpg would be smaller than base.jpg. Which exec command would I run to place overlay centered on top of base.jpg?

Thanks!

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

3条回答

  • dongnanman9093 dongnanman9093 11年前
    shell_exec("composite -gravity center ./images/watermark_horizontal.png {$this->path} {$this->path}");
    

    Here we go

    点赞 评论 复制链接分享
  • douzhi9635 douzhi9635 11年前

    Check out ImageMagick examples, especially the Compositing Images chapter. It has a number of ready-made real-world examples.

    点赞 评论 复制链接分享
  • dongyong8491 dongyong8491 5年前
    $image = new Imagick();
    $image->readImage("image.jpg");
    
    // Open the watermark
    $watermark = new Imagick();
    $watermark->readImage("watermark.png");
    
    // Overlay the watermark on the original image
    $image->compositeImage($watermark, imagick::COMPOSITE_OVER, 0, 0);
    
    // send the result to the browser
    header("Content-Type: image/" . $image->getImageFormat());
    
    点赞 评论 复制链接分享

为你推荐