dozc1071 2013-12-21 21:29 采纳率: 100%
浏览 274
已采纳

使用imageMagick如何使用蒙版并将2张图像合并为1张?

I have a JPEG template:

template image

I need put a JPEG image inside that grey mask and save it as a JPEG. (so resize the jpeg, and put it where the greay mask is).

Is there a way to do that using php and imagemagick extension ?

Regards

  • 写回答

1条回答 默认 最新

  • duannao3819 2013-12-22 06:53
    关注

    If you want your image to be 318px x 235px (to fit in the window of your template), you can resize using ImageMagick:

    convert photo-big.jpg -resize '318x235^' photo-small.jpg 
    

    The ^ insures that the small version will not be any smaller than the given dimensions, although one dimension may be bigger, in order to maintain the aspect ratio.

    In order to insert the resized image into your template, you'll need a third image to serve as a mask. The mask is only black and white: the white is where you want the photo to show up in your template, like this: mask for template

    Use the following line of code to create your composite image. The geometry indicates the offset in pixels (59 down and 15 over) to position the photo in the window:

    composite -geometry '+15+59' photo-small.jpg template.jpg mask.jpg comp.jpg
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度