7
7
8
8
if 'copy_opacity' in COMPOSITE_OPERATORS :
9
9
COPY_ALPHA = 'copy_opacity' # ImageMagick 6 name
10
+ NEEDS_NEGATE = False
10
11
else :
11
12
COPY_ALPHA = 'copy_alpha' # ImageMagick 7 name
13
+ NEEDS_NEGATE = True
12
14
13
15
14
16
def apply_to_image (image : BaseImage , * , color : str , radius : float , sigma : float , xoffset : float ,
@@ -18,8 +20,14 @@ def apply_to_image(image: BaseImage, *, color: str, radius: float, sigma: float,
18
20
new_width = image .width + 3 * xoffset
19
21
new_height = image .height + 3 * yoffset
20
22
23
+ if NEEDS_NEGATE :
24
+ channel = image .channel_images ['opacity' ].clone ()
25
+ channel .negate ()
26
+ else :
27
+ channel = image .channel_images ['opacity' ]
28
+
21
29
opacity = Image (width = new_width , height = new_height , pseudo = 'xc:white' )
22
- opacity .composite (image . channel_images [ 'opacity' ] , left = xoffset , top = yoffset )
30
+ opacity .composite (channel , left = xoffset , top = yoffset )
23
31
opacity .gaussian_blur (radius * image .width , sigma * image .width )
24
32
opacity .negate ()
25
33
opacity .modulate (50 )
@@ -28,8 +36,8 @@ def apply_to_image(image: BaseImage, *, color: str, radius: float, sigma: float,
28
36
shadow .composite (opacity , operator = COPY_ALPHA )
29
37
30
38
result = Image (width = new_width , height = new_height , pseudo = 'xc:transparent' )
39
+ result .composite (shadow )
31
40
result .composite (image )
32
- result .composite (shadow , operator = 'difference' )
33
41
34
42
trimmed = result .clone ()
35
43
trimmed .trim (color = Color ('transparent' ))
0 commit comments