Skip to main content

Image and PDF Compare

Project description

Visual Compare

Installation

pip install visual-compare

Examples

Compare images

from visual_compare.doc.visual import Visual

def get_path(filename):
    image_base = '../../files/images/'
    return image_base + filename

reference_image = get_path('123.png')
test_image = get_path('124.png')
vt = Visual()
is_diff, res = vt.compare_images(reference_image, test_image)
print(res)
assert is_diff is True

Result as follows

1.jpg

Compare images with mask

from visual_compare.doc.visual import Visual

def get_path(filename):
    image_base = '../../files/images/'
    return image_base + filename

reference_image = get_path('123.png')
test_image = get_path('124.png')
mask_images = [get_path('000.png')]
vt = Visual()
mask = vt.generate_mask(reference_image, mask_images)
is_diff, res = vt.compare_images(reference_image, test_image, mask=mask)
print(res)
assert is_diff is True

Result as follows

2.jpg

Compare images with OCR

from visual_compare.doc.visual import Visual

def get_path(filename):
    image_base = '../../files/images/'
    return image_base + filename

reference_image = get_path('123.png')
test_image = get_path('124.png')
vt = Visual()
is_diff, res = vt.compare_images(reference_image, test_image, force_ocr=True, lang=['ch_sim', 'en'])
print(res)
assert is_diff is True

Result as follows

3.jpg

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

visual-compare-1.0.2.3.tar.gz (31.4 kB view hashes)

Uploaded Source

Built Distribution

visual_compare-1.0.2.3-py3-none-any.whl (38.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page