2017-07-20 74 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

谢谢,我会检查出来。 –