Support copy_opacity rename in ImageMagick 7

This commit is contained in:
Quantum 2022-04-09 04:06:26 -04:00
parent b5308cbb1e
commit ffb9c5e24a

View file

@ -1,10 +1,15 @@
from typing import List
from wand.color import Color
from wand.image import BaseImage, Image
from wand.image import BaseImage, COMPOSITE_OPERATORS, Image
from win2xcur.cursor import CursorFrame
if 'copy_opacity' in COMPOSITE_OPERATORS:
COPY_ALPHA = 'copy_opacity' # ImageMagick 6 name
else:
COPY_ALPHA = 'copy_alpha' # ImageMagick 7 name
def apply_to_image(image: BaseImage, *, color: str, radius: float, sigma: float, xoffset: float,
yoffset: float) -> Image:
@ -20,7 +25,7 @@ def apply_to_image(image: BaseImage, *, color: str, radius: float, sigma: float,
opacity.modulate(50)
shadow = Image(width=new_width, height=new_height, pseudo='xc:' + color)
shadow.composite(opacity, operator='copy_opacity')
shadow.composite(opacity, operator=COPY_ALPHA)
result = Image(width=new_width, height=new_height, pseudo='xc:transparent')
result.composite(image)