Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Treath different image sizes as a diff #38

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions huxley/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,8 @@ def image_diff(path1, path2, outpath, diffcolor):

rmsdiff = rmsdiff_2011(im1, im2)

pix1 = im1.load()
pix2 = im2.load()

if im1.mode != im2.mode:
raise TestError('Different pixel modes between %r and %r' % (path1, path2))
if im1.size != im2.size:
raise TestError('Different dimensions between %r (%r) and %r (%r)' % (path1, im1.size, path2, im2.size))

mode = im1.mode

Expand All @@ -64,6 +59,19 @@ def image_diff(path1, path2, outpath, diffcolor):
else:
raise NotImplementedError('Unexpected PNG mode')

if im1.size != im2.size:
if im1.size > im2.size:
im3 = Image.new(im1.mode, im1.size, value)
im3.paste(im2, (0, 0), im2)
im2 = im3
else:
im3 = Image.new(im2.mode, im2.size, value)
im3.paste(im1, (0, 0), im1)
im1 = im3

pix1 = im1.load()
pix2 = im2.load()

width, height = im1.size

for y in xrange(height):
Expand Down