2017-07-20 83 views

回答

0

wand.image.Image.composite方法接受top & left參數。沒有太多的努力,通過側複合圖像側...

with Image(filename="rose:") as left: 
    with Image(filename="rose:") as right: 
    with Image(width=left.width+right.width, 
       height=max(left.height, right.height)) as output: 
     output.composite(image=left, left=0, top=0) 
     output.composite(image=right, left=left.width, top=0) 
     output.save(filename="hstack.png") 

hstack

...或堆疊...

with Image(filename="rose:") as top: 
    with Image(filename="rose:") as bottom: 
    with Image(width=max(top.width, bottom.width), 
       height=top.height + bottom.height) as output: 
     output.composite(image=top, left=0, top=0) 
     output.composite(image=bottom, left=0, top=top.height) 
     output.save(filename="vstack.png") 

vstack

當然,你可能能夠簡化上面的例子,或者使用wand.api.library來實現MagickAppendImage

+0

謝謝,我會檢查出來。 –