From 8123f714f4034289efc4ce7c9353a75c456ead0a Mon Sep 17 00:00:00 2001 From: Alex Tomkins Date: Sat, 14 Nov 2026 12:56:59 +0000 Subject: [PATCH] Allow background to be disabled --- pyimgproxy/image.py | 5 +++++ tests/test_image.py | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/pyimgproxy/image.py b/pyimgproxy/image.py index 78ff450..d62516b 100644 --- a/pyimgproxy/image.py +++ b/pyimgproxy/image.py @@ -347,6 +347,9 @@ def rotate(self, angle: int) -> "Image": """ return self.add_option("rotate", angle) + @overload + def background(self) -> "Image": ... + @overload def background(self, *, hex_color: str) -> "Image": ... @@ -367,6 +370,8 @@ def background( `hex_color` is a hex-coded value of the color. Useful when you convert an image with alpha-channel to JPEG. + With no arguments provided, disables any background manipulations. + Default: disabled """ if hex_color is not None: diff --git a/tests/test_image.py b/tests/test_image.py index 52d5c4b..fd54db2 100644 --- a/tests/test_image.py +++ b/tests/test_image.py @@ -182,6 +182,11 @@ def test_background_rgb(self): self.assertEqual(image.options, ["background:50:150:250"]) + def test_background_disabled(self): + image = self.image.background() + + self.assertEqual(image.options, ["background"]) + def test_background_alpha(self): image = self.image.background_alpha(alpha=0.1)