2016-05-08 3 views
0

私は、python-wandを使用してピカメラから撮影した画像にエッジを丸める作業を数日間行いました。私はそれがイメージをつかみ、以下にバナー/背景画像の上に合成する場所に今それを設定している:画像上のワンド丸みを帯びたエッジ

img = Image(filename=Picture)           
img.resize(1200, 800) 
bimg = Image(filename=Background) 
bimg.composite(img, left=300, top=200) 
bimg.save(filename=BPicture) 

すべてのヘルプは歓迎です!

答えて

3

wand.drawing.Drawing.rectangleを使用すると、角を丸くしてコンポジットチャネルでオーバーレイすることができます。

from wand.image import Image 
from wand.color import Color 
from wand.drawing import Drawing 

with Image(filename='rose:') as img: 
    img.resize(240, 160) 
    with Image(width=img.width, 
       height=img.height, 
       background=Color("white")) as mask: 

     with Drawing() as ctx: 
      ctx.fill_color = Color("black") 
      ctx.rectangle(left=0, 
          top=0, 
          width=mask.width, 
          height=mask.height, 
          radius=mask.width*0.1) # 10% rounding? 
      ctx(mask) 
     img.composite_channel('all_channels', mask, 'screen') 
     img.save(filename='/tmp/out.png') 

Wand rounded edges

私はあなたの質問を理解していれば今、あなたは、描画コンテキストで同じ手法が、複合Pictureを適用することができます。よく答え

with Image(filename='rose:') as img: 
    img.resize(240, 160) 
    with Image(img) as nimg: 
     nimg.negate() # For fun, let's negate the image for the background 
     with Drawing() as ctx: 
      ctx.fill_color = Color("black") 
      ctx.rectangle(left=0, 
          top=0, 
          width=nimg.width, 
          height=nimg.height, 
          radius=nimg.width*0.3) # 30% rounding? 
      ctx.composite('screen', 0, 0, nimg.width, nimg.height, img) 
      ctx(nimg) 
     nimg.save(filename='/tmp/out2.png') 

Wand rounded edges with background

+0

。あなたをアップアップ! –

関連する問題