Skip to content

Commit dd4ceff

Browse files
authored
FileIO extension for imshow() (#316)
When FileIO is present, imshow() will open an image using a dialog.
1 parent acaab89 commit dd4ceff

File tree

4 files changed

+19
-8
lines changed

4 files changed

+19
-8
lines changed

Project.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ StatsBase = "0.28, 0.29, 0.30, 0.31, 0.32, 0.33, 0.34"
3535
julia = "1.10"
3636
TestImages = "1.9"
3737

38+
[weakdeps]
39+
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
40+
41+
[extensions]
42+
ImageViewFileIOExt = "FileIO"
43+
3844
[extras]
3945
ImageCore = "a09fc81d-aa75-5fe9-8630-4744c3626534"
4046
ImageIO = "82e4d734-157c-48bb-816b-45c225c6df19"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ You should get a window with your image:
4141
![photo](readme_images/photo1.jpg)
4242

4343
You can use `imshow()` if you want to choose an image using a file
44-
dialog.
44+
dialog (requires [FileIO](https://github.com/JuliaIO/FileIO.jl)).
4545

4646
Try resizing the image window by dragging one of its corners; you'll
4747
see that the aspect ratio of the image is preserved when you

ext/ImageViewFileIOExt.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module ImageViewFileIOExt
2+
3+
using FileIO, ImageView, Gtk4
4+
5+
"""
6+
imshow()
7+
8+
Choose an image to display via a file dialog.
9+
"""
10+
ImageView.imshow() = imshow(load(open_dialog("Pick an image to display")))
11+
12+
end

src/ImageView.jl

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,6 @@ end
5959

6060
const window_wrefs = WeakKeyDict{Gtk4.GtkWindowLeaf,Nothing}()
6161

62-
"""
63-
imshow()
64-
65-
Choose an image to display via a file dialog.
66-
"""
67-
imshow() = imshow(load(open_dialog("Pick an image to display")))
68-
6962
"""
7063
imshow!(canvas, img) -> drawsignal
7164
imshow!(canvas, img::Observable, zr::Observable{ZoomRegion}) -> drawsignal

0 commit comments

Comments
 (0)