From ffb9c5e24a166e567041fbeb9283b641f29efef1 Mon Sep 17 00:00:00 2001 From: Quantum Date: Sat, 9 Apr 2022 04:06:26 -0400 Subject: [PATCH] Support copy_opacity rename in ImageMagick 7 --- win2xcur/shadow.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/win2xcur/shadow.py b/win2xcur/shadow.py index d987535..1f75101 100644 --- a/win2xcur/shadow.py +++ b/win2xcur/shadow.py @@ -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)