Skip to content

Commit 20b3ccb

Browse files
committed
Replaced _neon_blend with Image.blend
1 parent d241df1 commit 20b3ccb

File tree

2 files changed

+1
-52
lines changed

2 files changed

+1
-52
lines changed

Tests/test_imageops.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -631,22 +631,6 @@ def test_sobel_output_mode_and_size() -> None:
631631
assert out.size == img.size
632632

633633

634-
def test_neon_blend_alpha_zero() -> None:
635-
base = Image.new("RGB", (1, 1), (10, 20, 30))
636-
neon = Image.new("RGB", (1, 1), (200, 200, 200))
637-
638-
out = ImageOps._neon_blend(base, neon, alpha=0)
639-
assert out.getpixel((0, 0)) == (10, 20, 30)
640-
641-
642-
def test_neon_blend_alpha_one() -> None:
643-
base = Image.new("RGB", (1, 1), (10, 20, 30))
644-
neon = Image.new("RGB", (1, 1), (200, 200, 200))
645-
646-
out = ImageOps._neon_blend(base, neon, alpha=1)
647-
assert out.getpixel((0, 0)) == (200, 200, 200)
648-
649-
650634
def test_neon_effect_mode_and_size() -> None:
651635
img = Image.new("RGB", (20, 20))
652636
out = ImageOps.neon_effect(img)

src/PIL/ImageOps.py

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -689,41 +689,6 @@ def sobel(image: Image.Image) -> Image.Image:
689689
return out
690690

691691

692-
def _neon_blend(
693-
original: Image.Image, neon: Image.Image, alpha: float = 0.55
694-
) -> Image.Image:
695-
"""
696-
Blend the original image with its neon/glow layer
697-
698-
:param original: Image to blend whith neon layer
699-
:param neon: neon Layer
700-
:param alpha: controls intensity of neon effect
701-
:return: An image
702-
"""
703-
if alpha < 0:
704-
alpha = 0
705-
if alpha > 1:
706-
alpha = 1
707-
708-
out = Image.new("RGB", original.size)
709-
710-
for y in range(original.height):
711-
for x in range(original.width):
712-
value1 = original.getpixel((x, y))
713-
value2 = neon.getpixel((x, y))
714-
assert isinstance(value1, tuple)
715-
assert isinstance(value2, tuple)
716-
717-
out.putpixel(
718-
(x, y),
719-
tuple(
720-
int((1 - alpha) * value1[i] + alpha * value2[i]) for i in range(3)
721-
),
722-
)
723-
724-
return out
725-
726-
727692
def neon_effect(
728693
image: Image.Image, color: tuple[int, int, int] = (255, 0, 255), alpha: float = 0.2
729694
) -> Image.Image:
@@ -749,7 +714,7 @@ def neon_effect(
749714
tuple(glow.point(lambda value: min(255, int(value * c / 255))) for c in color),
750715
)
751716

752-
return _neon_blend(image, neon, alpha)
717+
return Image.blend(image, neon, alpha)
753718

754719

755720
def invert(image: Image.Image) -> Image.Image:

0 commit comments

Comments
 (0)