diff --git a/Project.toml b/Project.toml index 1f5c03a..47c94db 100644 --- a/Project.toml +++ b/Project.toml @@ -35,6 +35,12 @@ StatsBase = "0.28, 0.29, 0.30, 0.31, 0.32, 0.33, 0.34" julia = "1.10" TestImages = "1.9" +[weakdeps] +FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549" + +[extensions] +ImageViewFileIOExt = "FileIO" + [extras] ImageCore = "a09fc81d-aa75-5fe9-8630-4744c3626534" ImageIO = "82e4d734-157c-48bb-816b-45c225c6df19" diff --git a/README.md b/README.md index 5b92667..947005d 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ You should get a window with your image: ![photo](readme_images/photo1.jpg) You can use `imshow()` if you want to choose an image using a file -dialog. +dialog (requires [FileIO](https://github.com/JuliaIO/FileIO.jl)). Try resizing the image window by dragging one of its corners; you'll see that the aspect ratio of the image is preserved when you diff --git a/ext/ImageViewFileIOExt.jl b/ext/ImageViewFileIOExt.jl new file mode 100644 index 0000000..8e369e4 --- /dev/null +++ b/ext/ImageViewFileIOExt.jl @@ -0,0 +1,12 @@ +module ImageViewFileIOExt + +using FileIO, ImageView, Gtk4 + +""" + imshow() + +Choose an image to display via a file dialog. +""" +ImageView.imshow() = imshow(load(open_dialog("Pick an image to display"))) + +end diff --git a/src/ImageView.jl b/src/ImageView.jl index bdd296e..7c1ca6a 100644 --- a/src/ImageView.jl +++ b/src/ImageView.jl @@ -59,13 +59,6 @@ end const window_wrefs = WeakKeyDict{Gtk4.GtkWindowLeaf,Nothing}() -""" - imshow() - -Choose an image to display via a file dialog. -""" -imshow() = imshow(load(open_dialog("Pick an image to display"))) - """ imshow!(canvas, img) -> drawsignal imshow!(canvas, img::Observable, zr::Observable{ZoomRegion}) -> drawsignal