Get the total RGB or hexadecimal pixel differences between two images.
Project description
PixelDifference - Pixel differences between two images
Intro
This package is for comparing pixel differences between two images. It will check the same pixel positions on both images. This can be used to compare how different an image is to the original after compression or editing.
If one image is cropped, for example, you can use ignoreSize=True to only compare the area which is present in both images.
Requirements
You need python3 and pillow to use this package.
pip install pillow
Installation
pip install pixeldifference
Usage
# Import packages
from pixeldifference import PixelDifference
from PIL import Image
# Load two images from your device
# You need to change the image paths to your images
imageOne = Image.open('/path/to/imageOne.jpg', 'r')
imageTwo = Image.open('/path/to/imageTwo.jpg', 'r')
# Initialise
pd = PixelDifference(imageOne, imageTwo)
# The total number of pixels checked
totalpixels = pd.total
# The percentage of different pixels compared to the total checked area
percentdifferent = pd.percent
# The total number of different pixels in the checked area
pixelsdifferent = pd.pixels
Advanced Settings
Images of Different Size
This will compare an area which exists in both images. Use this if one image is cropped, for example.
# Use ignoreSize=True
pd = PixelDifference(imageOne, imageTwo, ignoreSize=True)
Compare Pixels in Hexadecimal (eg. #FFFFFF)
This will convert all the pixels to hexadecimal values, like #FFFFFF, before comparison. The default compares the RGB values.
# Use convert2Hex=True
pd = PixelDifference(imageOne, imageTwo, convert2Hex=True)
Features
- Compare two images for differences, pixel by pixel
- Compare pixels in RGB or hexadecimal values
- Use different sized images
- Image difference in pixels, and percentage of total area
To Do
- Add image file size comparison
- Improve Readme
- Command line arguments
- More tests
- Handle images from string paths
- Performance tests/improvements
- Allow for more than 2 images
Changes
-v1.0.0 (June 12th, 2021)
Initial release
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pixeldifference-1.0.0.tar.gz
.
File metadata
- Download URL: pixeldifference-1.0.0.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d7b3c0f7f70ee02ce06ee422a18d4cd473e2305b4866fc67e7582baaad7723f |
|
MD5 | a52f8155101b93bc4209da534dbaaefc |
|
BLAKE2b-256 | 8e8e8d8e2e82c465e8250d8c9c824cc3f5cf35b94fb06f3aa4217faa4d9d6c07 |
File details
Details for the file pixeldifference-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: pixeldifference-1.0.0-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 053c6b7f6011bb09b91a475f3ce1f86551384a0893cf721b315071cc8f887c27 |
|
MD5 | e409cb8c70b116194e901f9972fd4b6d |
|
BLAKE2b-256 | 82f26c08fab755be4781bb64b26d31fd5f9570146d1d53d72414c6987a855a91 |