Skip to content

Commit

Permalink
rel 2024.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
FredHappyface committed Jan 19, 2024
1 parent 9bb5365 commit 1f8dc44
Show file tree
Hide file tree
Showing 13 changed files with 251 additions and 196 deletions.
57 changes: 31 additions & 26 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,44 +1,49 @@
repos:
- repo: https://github.com/FHPythonUtils/Blackt
rev: '2022.0.3'
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.14
hooks:
- id: blackt
- id: ruff
args: [ --fix ]

- repo: https://github.com/RobertCraigie/pyright-python
rev: v1.1.347
hooks:
- id: pyright

- repo: https://github.com/pycqa/isort
rev: 5.12.0
- repo: https://github.com/FHPythonUtils/Blackt
rev: '2024.0.1'
hooks:
- id: isort
- id: blackt

- repo: https://github.com/pycqa/pylint
rev: v3.0.0a6
- repo: https://github.com/Lucas-C/pre-commit-hooks-safety
rev: v1.3.2
hooks:
- id: pylint
exclude: "tests/"
args: [--disable=import-error,--jobs=0]
- id: python-safety-dependencies-check
files: pyproject.toml

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: trailing-whitespace
exclude: "tests/"
- id: end-of-file-fixer
exclude: "tests/"
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: check-json
- id: check-merge-conflict
- id: check-shebang-scripts-are-executable
- id: check-symlinks
- id: check-toml
- id: check-vcs-permalinks
- id: check-yaml
- id: detect-private-key
- id: mixed-line-ending

- repo: https://github.com/asottile/pyupgrade
rev: v3.7.0
hooks:
- id: pyupgrade
args: [--py38-plus]
- repo: https://github.com/boidolr/pre-commit-images
rev: v1.2.1
rev: v1.5.1
hooks:
- id: optimize-avif
exclude: "tests/"
- id: optimize-jpg
exclude: "tests/"
- id: optimize-png
exclude: "tests/"
- id: optimize-svg
exclude: "tests/"
- id: optimize-webp
exclude: "tests/"

exclude: "tests/data|documentation/reference"
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
All major and minor version changes will be documented in this file. Details of
patch-level version changes can be found in [commit messages](../../commits/master).

## 2024.0.1 - 2024/01/19

- update dependencies
- ruff linting

## 2024 - 2024/01/07

- update dependencies
Expand Down
2 changes: 1 addition & 1 deletion blendmodes/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"""Use this module to apply a number of blending modes to a background and foreground image
"""Use this module to apply a number of blending modes to a background and foreground image.
"""
14 changes: 11 additions & 3 deletions blendmodes/blend.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,9 @@ def destin(
Destination which overlaps the source, replaces the source.
Fa = 0; Fb = αs
co = αb x Cb x αs
αo = αb x αs
Fa = 0; Fb = as
co = ab x Cb x as
ao = ab x as
"""
del foregroundColour # Not used by function
outAlpha = backgroundAlpha * foregroundAlpha
Expand Down Expand Up @@ -361,9 +361,11 @@ def imageIntToFloat(image: np.ndarray) -> np.ndarray:
"""Convert a numpy array representing an image to an array of floats.
Args:
----
image (np.ndarray): numpy array of ints
Returns:
-------
np.ndarray: numpy array of floats
"""
return image / 255
Expand All @@ -373,9 +375,11 @@ def imageFloatToInt(image: np.ndarray) -> np.ndarray:
"""Convert a numpy array representing an image to an array of ints.
Args:
----
image (np.ndarray): numpy array of floats
Returns:
-------
np.ndarray: numpy array of ints
"""
clippedIm = np.clip((image * 255).round(), 0, 255)
Expand All @@ -388,11 +392,13 @@ def blend(background: np.ndarray, foreground: np.ndarray, blendType: BlendType)
"""Blend pixels.
Args:
----
background (np.ndarray): background
foreground (np.ndarray): foreground
blendType (BlendType): the blend type
Returns:
-------
np.ndarray: new array representing the image
background: np.ndarray,
Expand Down Expand Up @@ -457,12 +463,14 @@ def blendLayers(
"""Blend layers using numpy array.
Args:
----
background (Image.Image): background layer
foreground (Image.Image): foreground layer (must be same size as background)
blendType (BlendType): The blendtype
opacity (float): The opacity of the foreground image
Returns:
-------
Image.Image: combined image
"""
# Convert the Image.Image to a numpy array
Expand Down
25 changes: 2 additions & 23 deletions blendmodes/imagetools.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,24 @@
"""
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)
Expand Down
Loading

0 comments on commit 1f8dc44

Please sign in to comment.