Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
A fast pixel-level image comparison library, originally created to compare screenshots in tests. Now with additional support of PIL.Image instances Python port of https://github.com/mapbox/pixelmatch.
Features accurate anti-aliased pixels detection and perceptual color difference metrics.
from pixelmatch import pixelmatch
num_diff_pixels = pixelmatch(img1, img2, 800, 600, diff, threshold=0.1)
Implements ideas from the following papers:
python -m pip install pixelmatch
from PIL import Image
from pixelmatch.contrib.PIL import pixelmatch
img_a = Image.open("a.png")
img_b = Image.open("b.png")
img_diff = Image.new("RGBA", img_a.size)
# note how there is no need to specify dimensions
mismatch = pixelmatch(img_a, img_b, img_diff, includeAA=True)
img_diff.save("diff.png")
from pixelmatch import pixelmatch
width, height = 1920, 1080
img_a = [R1, G1, B1, A1, R2, B2, G2, A2, ...]
img_b = [R1, G1, B1, A1, R2, B2, G2, A2, ...]
data_diff = [0] * len(img_a)
mismatch = pixelmatch(img_a, img_b, width, height, data_diff, includeAA=True)
img1
, img2
— RGBA Image data of the images to compare. Note: image dimensions must be equal.width
, height
— Width and height of the images.output
— Image data to write the diff to, or None
if don't need a diff image. Note that all three images need to have the same dimensions.threshold
— Matching threshold, ranges from 0
to 1
. Smaller values make the comparison more sensitive. 0.1
by default.includeAA
— If true
, disables detecting and ignoring anti-aliased pixels. false
by default.alpha
— Blending factor of unchanged pixels in the diff output. Ranges from 0
for pure white to 1
for original brightness. 0.1
by default.aa_color
— The color of anti-aliased pixels in the diff output in [R, G, B]
format. [255, 255, 0]
by default.diff_color
— The color of differing pixels in the diff output in [R, G, B]
format. [255, 0, 0]
by default.diff_mask
— Draw the diff over a transparent background (a mask), rather than over the original image. Will not draw anti-aliased pixels (if detected).fail_fast
- If true, will return after first different pixel.Compares two images, writes the output diff and returns the number of mismatched pixels.
Compares two images, writes the output diff and returns the number of mismatched pixels. Exact same API as pixelmatch.pixelmatch
except for the important fact that it takes instances of PIL.Image for image parameters (img1
, img2
, and output
) and the width/size need not be specified.
expected | actual | diff |
---|---|---|
Sequence
instead of List
for RGBTuple
poetry_core
#81options
parameter #38FAQs
A pixel-level image comparison library.
We found that pixelmatch demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.