Skip to main content

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

Metadata

Release files for pixeldifference 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pixeldifference 1.0.0
File Size Uploaded
pixeldifference-1.0.0.tar.gz 7.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pixeldifference 1.0.0
File Interpreter ABI Platform
pixeldifference-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 14.8 kB

Release files / pixeldifference-1.0.0.tar.gz

Download URL pixeldifference-1.0.0.tar.gz
Size 7.2 kB
Tags Source
SHA-256 checksum
How to use checksums
2d7b3c0f7f70ee02ce06ee422a18d4cd473e2305b4866fc67e7582baaad7723f
BLAKE2b-256 checksum
How to use checksums
8e8e8d8e2e82c465e8250d8c9c824cc3f5cf35b94fb06f3aa4217faa4d9d6c07
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / pixeldifference-1.0.0-py3-none-any.whl

Download URL pixeldifference-1.0.0-py3-none-any.whl
Size 7.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
053c6b7f6011bb09b91a475f3ce1f86551384a0893cf721b315071cc8f887c27
BLAKE2b-256 checksum
How to use checksums
82f26c08fab755be4781bb64b26d31fd5f9570146d1d53d72414c6987a855a91
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page