Skip to content

PSNR metric returns all: 1 resulting in incorrect results #20

@vishaalagartha

Description

@vishaalagartha

When I run compare -verbose -metric psnr test.png test.png output.png (comparison on the same file)` this is the output I get:

test.png PNG 3456x2234 3456x2234+0+0 8-bit TrueColorAlpha sRGB 1.03965MiB 0.060u 0:00.063
test.png PNG 3456x2234 3456x2234+0+0 8-bit TrueColorAlpha sRGB 1.03965MiB 0.050u 0:00.050
Image: test.png
  Channel distortion: PSNR
    red: 1
    green: 1
    blue: 1
    alpha: 0
    all: 1
writing raw profile: type=icc, length=4064
writing raw profile: type=xmp, length=450
test.png=>output.png PNG 3456x2234 8-bit sRGB 1.03965MiB 0.640u 0:00.417

It appears that imagemagick can also output 1 if the files are identical? Hence, shouldn't this line (https://github.com/bgeron/diff-pdf-visually/blob/16513817e5c116507b3e08e4cdca72b1d53e7463/diff_pdf_visually/diff.py#L79C1-L80C1)
all_num = INFINITY if (all_str == "0" or all_str == "1.#INF") else float(all_str)
be changed to
all_num = INFINITY if (all_str == "0" or all_str == "1.#INF" or all_str == "1") else float(all_str)
?

Thanks in advance! I manually changed this in my site_packages and things to be working fine now.

ImageMagick version: 7.1.2-0 Q16-HDRI aarch64 23234
diff_pdf_visually version: 1.3.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions