Skip to content

Commit

Permalink
Call GetImageDistortion instead of IsImagesEqual to fix the issue rep…
Browse files Browse the repository at this point in the history
…orted in #1342 (#1343)
  • Loading branch information
dlemstra committed Jul 15, 2022
1 parent c97f107 commit 7decabd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ext/RMagick/rmimage.c
Expand Up @@ -5205,6 +5205,7 @@ Image_difference(VALUE self, VALUE other)
Image *image2;
VALUE mean, nmean, nmax;
#if defined(IMAGEMAGICK_7)
double distortion;
ExceptionInfo *exception;
#endif

Expand All @@ -5214,7 +5215,7 @@ Image_difference(VALUE self, VALUE other)

#if defined(IMAGEMAGICK_7)
exception = AcquireExceptionInfo();
IsImagesEqual(image, image2, exception);
GetImageDistortion(image, image2, MeanErrorPerPixelErrorMetric, &distortion, exception);
CHECK_EXCEPTION();
DestroyExceptionInfo(exception);
#else
Expand Down
3 changes: 3 additions & 0 deletions spec/rmagick/image/difference_spec.rb
Expand Up @@ -7,8 +7,11 @@
expect(result).to be_instance_of(Array)
expect(result.length).to eq(3)
expect(result[0]).to be_instance_of(Float)
expect(result[0]).not_to eq(0.0)
expect(result[1]).to be_instance_of(Float)
expect(result[1]).not_to eq(0.0)
expect(result[2]).to be_instance_of(Float)
expect(result[2]).not_to eq(0.0)

expect { image1.difference(2) }.to raise_error(NoMethodError)
image2.destroy!
Expand Down

0 comments on commit 7decabd

Please sign in to comment.