Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable image display using ImageShow #41

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Distances = "b4f34e82-e78d-54a5-968a-f98e89d6e8f7"
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
ImageCore = "a09fc81d-aa75-5fe9-8630-4744c3626534"
ImageInTerminal = "d8c32880-2388-543b-8c61-d9f865259254"
ImageShow = "4e3cecfd-b093-5904-9786-8bbb286a6a31"
MosaicViews = "e94cdb99-869f-56ef-bcf0-1ae2bcbe0389"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
SHA = "ea8e919c-243c-51af-8825-aaa63cd721ce"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Expand All @@ -19,6 +21,8 @@ Distances = "0.7, 0.8"
FileIO = "1"
ImageCore = "0.8.1"
ImageInTerminal = "0.3, 0.4"
ImageShow = "0.2"
MosaicViews = "0.2"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MosaicView is planned to be reexported by ImageShow

JuliaImages/ImageShow.jl#19

julia = "1"

[extras]
Expand Down
2 changes: 2 additions & 0 deletions src/ReferenceTests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ using ImageInTerminal
using SHA
using DeepDiffs
using Random
using MosaicViews
using ImageShow

export
@withcolor,
Expand Down
23 changes: 20 additions & 3 deletions src/render.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,25 @@ end

## 2 arg form render for comparing
function render(mode::BeforeAfter, reference, actual)
if displayable(MIME("image/png"))
render(MIME("image/png"), mode, reference, actual)
else
render(MIME("text/plain"), mode, reference, actual)
end
end
function render(::MIME"text/plain", mode::BeforeAfter, reference, actual)
println("- REFERENCE -------------------")
render_item(mode, reference)
println("-------------------------------")
println("- ACTUAL ----------------------")
render_item(mode, actual)
println("-------------------------------")
end
function render(::MIME"image/png", mode::BeforeAfterImage, reference, actual)
println("- REFERENCE --------|--------- ACTUAL -")
display(MIME("image/png"), mosaicview(reference, actual; nrow=1, npad=5))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought MIME("image/png") or "image/png" would work, but this still renders images both in atom plot panel and in terminal 😕

end

function render(::Diff, reference, actual)
println("- DIFF ------------------------")
@withcolor println(deepdiff(reference, actual))
Expand All @@ -39,11 +51,16 @@ end

## 1 arg form render for new content
function render(mode::RenderMode, actual)
println("- NEW CONTENT -----------------")
render_item(mode, actual)
println("-------------------------------")
if displayable(MIME("image/png"))
display(MIME("image/png"), actual)
else
println("- NEW CONTENT -----------------")
render_item(mode, actual)
println("-------------------------------")
end
end


"""
default_rendermode(::DataFormat, actual)

Expand Down