diff options
author | ThereforeGames <95403634+ThereforeGames@users.noreply.github.com> | 2022-12-11 22:59:59 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-11 22:59:59 +0000 |
commit | 00ca6a6db4674713a10d1de312559cb924ed3c55 (patch) | |
tree | 467a1107f8c27f625511e8589bb1d919ceba3b5b /venv/Lib/site-packages/blendmodes/imagetools.py | |
parent | 685f9631b56ff8bd43bce24ff5ce0f9a0e9af490 (diff) | |
download | stable-diffusion-webui-gfx803-00ca6a6db4674713a10d1de312559cb924ed3c55.tar.gz stable-diffusion-webui-gfx803-00ca6a6db4674713a10d1de312559cb924ed3c55.tar.bz2 stable-diffusion-webui-gfx803-00ca6a6db4674713a10d1de312559cb924ed3c55.zip |
Add files via upload
Diffstat (limited to 'venv/Lib/site-packages/blendmodes/imagetools.py')
-rw-r--r-- | venv/Lib/site-packages/blendmodes/imagetools.py | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/venv/Lib/site-packages/blendmodes/imagetools.py b/venv/Lib/site-packages/blendmodes/imagetools.py new file mode 100644 index 00000000..834b7c86 --- /dev/null +++ b/venv/Lib/site-packages/blendmodes/imagetools.py @@ -0,0 +1,48 @@ +"""Do stuff to images to prepare them.
+"""
+from __future__ import annotations
+
+import warnings
+
+from deprecation import deprecated
+from PIL import Image
+
+
+@deprecated(deprecated_in="2021.1", removed_in="", details="use renderWAlphaOffset")
+def rasterImageOA( # pylint:disable=missing-function-docstring
+ image: Image.Image, size: tuple[int, int], alpha: float = 1.0, offsets: tuple[int, int] = (0, 0)
+) -> Image.Image:
+ warnings.warn(
+ "Call to deprecated function rasterImageOA.", category=DeprecationWarning, stacklevel=2
+ )
+ return renderWAlphaOffset(image, size, alpha, offsets)
+
+
+@deprecated(deprecated_in="2021.1", removed_in="", details="use renderWAlphaOffset")
+def rasterImageOffset( # pylint:disable=missing-function-docstring
+ image: Image.Image, size: tuple[int, int], offsets: tuple[int, int] = (0, 0)
+) -> Image.Image:
+ warnings.warn(
+ "Call to deprecated function rasterImageOffset.", category=DeprecationWarning, stacklevel=2
+ )
+ return renderWAlphaOffset(image, size, 1, offsets)
+
+
+def renderWAlphaOffset(
+ image: Image.Image, size: tuple[int, int], alpha: float = 1.0, offsets: tuple[int, int] = (0, 0)
+) -> Image.Image:
+ """Render an image with offset and alpha to a given size.
+
+ Args:
+ image (Image.Image): pil image to draw
+ size (tuple[int, int]): width, height as a tuple
+ alpha (float, optional): alpha transparency. Defaults to 1.0.
+ offsets (tuple[int, int], optional): x, y offsets as a tuple.
+ Defaults to (0, 0).
+
+ Returns:
+ Image.Image: new image
+ """
+ imageOffset = Image.new("RGBA", size)
+ imageOffset.paste(image.convert("RGBA"), offsets, image.convert("RGBA"))
+ return Image.blend(Image.new("RGBA", size), imageOffset, alpha)
|