Skip to content

diffviewer fails to show differences in some PNG files #9

Closed

Description

@wch

With these two files, there are a few pixels that are different, but the visual diff does not color them in red.
However, magick::image_compare() does show the differences.

oldfile <- "file1.png"
newfile <- "file2.png"

library(magick)
old <- magick::image_read(oldfile)
new <- magick::image_read(newfile)

# Shows difference
image_compare(old, new)

# Does not show difference
library(diffviewer)
diffviewer::visual_diff(oldfile, newfile)

grided_default new
grided_default

This is the difference image generated by image_compare(). I've added arrows pointing to the pixels that are different.

diff

Here's the info about the pixels that are different:

old_data <- old[[1]]
new_data <- new[[1]]

idx <- old_data != new_data
which(idx, arr.ind = TRUE)
#>       dim1 dim2 dim3
#>  [1,]    1  512  185
#>  [2,]    2  512  185
#>  [3,]    3  512  185
#>  [4,]    1  512  196
#>  [5,]    2  512  196
#>  [6,]    3  512  196
#>  [7,]    1 1022  670
#>  [8,]    2 1022  670
#>  [9,]    3 1022  670
#> [10,]    1 1022  686
#> [11,]    2 1022  686
#> [12,]    3 1022  686
#> [13,]    1 1022 1136
#> [14,]    2 1022 1136
#> [15,]    3 1022 1136

old_data[idx]
#>  [1] 0f 82 fe 0e 81 fe e6 e6 e6 d7 d7 d7 e6 e6 e6

new_data[idx]
#>  [1] 00 7b ff 00 7b ff e7 e7 e7 d8 d8 d8 e7 e7 e7

cc @nstrayer

Activity

  1. wch commented on Jun 16, 2021

    @wch
    MemberAuthor

    I've fixed this in rstudio/shinytest#391, and the same fix should work here.

  2. hadley commented on Jun 16, 2021

    @hadley
    Member

    Would you mind doing a PR?

  3. added 3 commits that reference this issue on Jun 16, 2021
    8457c78
    f2526e4
    6189e5b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions