Skip to content

Commit

Permalink
Support copy_opacity rename in ImageMagick 7
Browse files Browse the repository at this point in the history
  • Loading branch information
quantum5 committed Apr 9, 2022
1 parent b5308cb commit ffb9c5e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions win2xcur/shadow.py
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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)
Expand Down

0 comments on commit ffb9c5e

Please sign in to comment.