# This used to work (Tk, Image, ImageView)

**URL:** <https://discourse.julialang.org/t/this-used-to-work-tk-image-imageview/136745>\
**Category:** General Usage\
**Tags:** package, images, imageview, tk\
**Created:** [April 17, 2026, 12:24am UTC](https://discourse.julialang.org/t/this-used-to-work-tk-image-imageview/136745 "2026-04-17T00:24:34Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [April 17, 2026, 12:24am UTC](https://discourse.julialang.org/t/this-used-to-work-tk-image-imageview/136745/1 "2026-04-17T00:24:34Z")

</div>

```julia-auto
using NIfTI, Tk, Images, ImageView

function mriview(ni::NIVolume, xy=["x", "z"], zoom::Int=5)
    img = Image(ni.raw, ["spatialorder" => ["x", "y", "z"], "timedim" => 4, "colorspace" => "Gray",
                         "pixelspacing"=>voxel_size(ni.header)])
    img = scale(scaleminmax(img), img)
    imgc, imgslice = display(img, xy=xy)
    tksize = get_size(toplevel(imgc))
    controlheight = tksize[2] - size(img, xy[2])
    set_size(toplevel(imgc), max(tksize[1], size(img, xy[1])*zoom),
                             size(img, xy[2])*zoom+controlheight)
    (imgc, imgslice)
end
mriview(path::String) = mriview(niread(path, mmap=true))

```

No more. Something must have changed in the api?

Any ideas?

---

<div class="post-metadata">

**Author:** ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)\
**Post date:** [April 17, 2026, 12:57am UTC](https://discourse.julialang.org/t/this-used-to-work-tk-image-imageview/136745/2 "2026-04-17T00:57:04Z")

</div>

> [@Please read: make it easier to help you](https://discourse.julialang.org/t/please-read-make-it-easier-to-help-you/14757):
>
> Welcome to the Julia Discourse! We are enthusiastic about helping Julia programmers, both beginner and experienced. This public service announcement (PSA) outlines best practices when asking for help. Following these points makes it easier for us to help you and more likely you’ll get a prompt, useful answer. Keywords are highlighted to make it easier to refer to specific points. Choose a descriptive title that captures the key part of your question, eg “plots with multiple axes” instead of …

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [April 17, 2026, 4:12am UTC](https://discourse.julialang.org/t/this-used-to-work-tk-image-imageview/136745/3 "2026-04-17T04:12:48Z")

</div>

We need the image file that causes your code to fail, along with the stack trace.

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [April 17, 2026, 1:24pm UTC](https://discourse.julialang.org/t/this-used-to-work-tk-image-imageview/136745/4 "2026-04-17T13:24:35Z")

</div>

Thanks, Uwe. But my idea was to see if anyone was already using the combo (Tk + Images + ImageView) and could spot the problem at first sight. If you (or anyone else) are not familiar with this, don’t disturb yourself over it. (The problem is the `Image` no longer takes the arguments indicated – the API must have changed. It is not clear how to use it from the documentation.)

---

<div class="post-metadata">

**Author:** ![adienes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/adienes/32/37459_2.png) [@adienes](https://discourse.julialang.org/u/adienes)\
**Post date:** [April 17, 2026, 1:41pm UTC](https://discourse.julialang.org/t/this-used-to-work-tk-image-imageview/136745/5 "2026-04-17T13:41:10Z")

</div>

pasting your original question into AI it says this relies on several deprecated and pre-1.0 apis, and suggested the following

```julia-auto
using NIfTI
using Images
using ImageView

"""
    mriview(path::String)

Reads a NIfTI file and opens an interactive ImageView window.
"""
function mriview(path::String)
    # 1. Read the volume using memory mapping for efficiency
    ni = niread(path, mmap=true)
    
    # 2. Extract the raw numerical array
    raw_data = ni.raw
    
    # 3. Normalize the data to [0, 1] for visual display
    # MRI data is often stored as Int16 or Float32 with arbitrary ranges
    min_val = minimum(raw_data)
    max_val = maximum(raw_data)
    range_val = max_val > min_val ? (max_val - min_val) : 1.0
    
    # Broadcast normalization and cast to the Gray colorspace
    img_gray = Gray.((raw_data .- min_val) ./ range_val)
    
    # 4. Display the image
    # imshow returns a dictionary containing the GTK window state and canvas
    guidict = imshow(img_gray)
    
    return guidict
end

```

maybe that is a useful starting point?

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [April 17, 2026, 2:04pm UTC](https://discourse.julialang.org/t/this-used-to-work-tk-image-imageview/136745/6 "2026-04-17T14:04:56Z")

</div>

That is good, thanks, but the input is a 3d image. I knew how to load the data: the problem was Tk’s `Image`. I tried Copilot, but it did not work.
