Skip to content

Commit ffb9c5e

Browse files
committed
Support copy_opacity rename in ImageMagick 7
1 parent b5308cb commit ffb9c5e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

win2xcur/shadow.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
from typing import List
22

33
from wand.color import Color
4-
from wand.image import BaseImage, Image
4+
from wand.image import BaseImage, COMPOSITE_OPERATORS, Image
55

66
from win2xcur.cursor import CursorFrame
77

8+
if 'copy_opacity' in COMPOSITE_OPERATORS:
9+
COPY_ALPHA = 'copy_opacity' # ImageMagick 6 name
10+
else:
11+
COPY_ALPHA = 'copy_alpha' # ImageMagick 7 name
12+
813

914
def apply_to_image(image: BaseImage, *, color: str, radius: float, sigma: float, xoffset: float,
1015
yoffset: float) -> Image:
@@ -20,7 +25,7 @@ def apply_to_image(image: BaseImage, *, color: str, radius: float, sigma: float,
2025
opacity.modulate(50)
2126

2227
shadow = Image(width=new_width, height=new_height, pseudo='xc:' + color)
23-
shadow.composite(opacity, operator='copy_opacity')
28+
shadow.composite(opacity, operator=COPY_ALPHA)
2429

2530
result = Image(width=new_width, height=new_height, pseudo='xc:transparent')
2631
result.composite(image)

0 commit comments

Comments
 (0)