Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pyimgproxy/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": ...

Expand All @@ -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:
Expand Down
5 changes: 5 additions & 0 deletions tests/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down