diffimg
Advanced tools
| Metadata-Version: 1.1 | ||
| Name: diffimg | ||
| Version: 0.1.8 | ||
| Version: 0.1.9 | ||
| Summary: Get the % difference in images + generate a diff image | ||
@@ -9,5 +9,5 @@ Home-page: https://github.com/nicolashahn/python-image-diff | ||
| License: UNKNOWN | ||
| Download-URL: https://github.com/nicolashahn/python-image-diff/archive/v0.1.8.tar.gz | ||
| Download-URL: https://github.com/nicolashahn/python-image-diff/archive/v0.1.9.tar.gz | ||
| Description: UNKNOWN | ||
| Keywords: diff,difference,image | ||
| Platform: UNKNOWN |
+19
-9
| #!/usr/bin/env python | ||
| # return the % difference of two given images | ||
| # only works with images of the same file type | ||
| """ | ||
| Return the % difference of two given images. | ||
| Only works with images of the same file type and color channels. | ||
| """ | ||
| from __future__ import print_function | ||
| from PIL import Image, ImageChops, ImageStat | ||
@@ -10,8 +13,9 @@ | ||
| def diff(im1_file, | ||
| im2_file, | ||
| delete_diff_file=False, | ||
| def diff(im1_file, | ||
| im2_file, | ||
| delete_diff_file=False, | ||
| diff_img_file=DIFF_IMG_FILE): | ||
| '''Calculate the difference between two images of the same size | ||
| by comparing channel values at the pixel level. | ||
| by comparing channel values at the pixel level. | ||
@@ -22,8 +26,14 @@ `delete_diff_file`: removes the diff image after ratio found | ||
| # Generate diff image in memory. | ||
| im1 = Image.open(im1_file) | ||
| im2 = Image.open(im2_file) | ||
| diff_img = ImageChops.difference(im1,im2) | ||
| # Ensure we have the same color channels (RGBA vs RGB) | ||
| if im1.mode != im2.mode: | ||
| raise ValueError(("Differing color modes:\n {}: {}\n {}: {}\n" | ||
| "Ensure image color modes are the same." | ||
| ).format(im1_file, im1.mode, im2_file, im2.mode)) | ||
| # Generate diff image in memory. | ||
| diff_img = ImageChops.difference(im1, im2) | ||
| if not delete_diff_file: | ||
@@ -30,0 +40,0 @@ diff_img.convert('RGB').save(diff_img_file) |
+15
-13
@@ -1,5 +0,7 @@ | ||
| from __init__ import diff, DIFF_IMG_FILE | ||
| from __future__ import print_function | ||
| import argparse | ||
| import sys | ||
| from __init__ import diff, DIFF_IMG_FILE | ||
| def get_args(): | ||
@@ -9,22 +11,22 @@ parser = argparse.ArgumentParser( | ||
| and/or find difference percentage') | ||
| parser.add_argument('image1', | ||
| type=str, | ||
| parser.add_argument('image1', | ||
| type=str, | ||
| help='first image') | ||
| parser.add_argument('image2', | ||
| type=str, | ||
| parser.add_argument('image2', | ||
| type=str, | ||
| help='second image') | ||
| parser.add_argument('--ratio', '-r', | ||
| dest='use_ratio', | ||
| action='store_true', | ||
| dest='use_ratio', | ||
| action='store_true', | ||
| help='return a ratio instead of percentage') | ||
| parser.add_argument('--delete', '-d', | ||
| dest='delete_diff_file', | ||
| action='store_true', | ||
| action='store_true', | ||
| help='delete diff image file') | ||
| parser.add_argument('--filename', '-f', | ||
| dest='diff_img_file', | ||
| dest='diff_img_file', | ||
| type=str, | ||
| default=DIFF_IMG_FILE, | ||
| help='filename with valid extension to store diff image \ | ||
| (defaults to diff_img.jpg)') | ||
| (defaults to diff_img.jpg)') | ||
| return parser.parse_args() | ||
@@ -34,5 +36,5 @@ | ||
| args = get_args() | ||
| diff_ratio = diff(args.image1, | ||
| args.image2, | ||
| args.delete_diff_file, | ||
| diff_ratio = diff(args.image1, | ||
| args.image2, | ||
| args.delete_diff_file, | ||
| args.diff_img_file) | ||
@@ -39,0 +41,0 @@ if args.use_ratio: |
+2
-2
| Metadata-Version: 1.1 | ||
| Name: diffimg | ||
| Version: 0.1.8 | ||
| Version: 0.1.9 | ||
| Summary: Get the % difference in images + generate a diff image | ||
@@ -9,5 +9,5 @@ Home-page: https://github.com/nicolashahn/python-image-diff | ||
| License: UNKNOWN | ||
| Download-URL: https://github.com/nicolashahn/python-image-diff/archive/v0.1.8.tar.gz | ||
| Download-URL: https://github.com/nicolashahn/python-image-diff/archive/v0.1.9.tar.gz | ||
| Description: UNKNOWN | ||
| Keywords: diff,difference,image | ||
| Platform: UNKNOWN |
+12
-12
@@ -5,15 +5,15 @@ try: | ||
| from distutils.core import setup | ||
| version = '0.1.8' | ||
| VERSION = '0.1.9' | ||
| setup( | ||
| name = 'diffimg', | ||
| packages = ['diffimg'], # this must be the same as the name above | ||
| version = version, | ||
| description = 'Get the % difference in images + generate a diff image', | ||
| author = 'Nicolas Hahn', | ||
| author_email = 'nicolas@stonespring.org', | ||
| url = 'https://github.com/nicolashahn/python-image-diff', | ||
| download_url = 'https://github.com/nicolashahn/python-image-diff/archive/v{}.tar.gz'.format(version), | ||
| keywords = ['diff', 'difference', 'image'], | ||
| classifiers = [], | ||
| install_requires = ['Pillow>=4.3'], | ||
| name='diffimg', | ||
| packages=['diffimg'], # this must be the same as the name above | ||
| version=VERSION, | ||
| description='Get the % difference in images + generate a diff image', | ||
| author='Nicolas Hahn', | ||
| author_email='nicolas@stonespring.org', | ||
| url='https://github.com/nicolashahn/python-image-diff', | ||
| download_url='https://github.com/nicolashahn/python-image-diff/archive/v{}.tar.gz'.format(VERSION), | ||
| keywords=['diff', 'difference', 'image'], | ||
| classifiers=[], | ||
| install_requires=['Pillow>=4.3'], | ||
| ) |
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
4631
8.58%95
10.47%