# Read and write/save 3-D image

**URL:** <https://discourse.julialang.org/t/read-and-write-save-3-d-image/26978>\
**Category:** Visualization\
**Tags:** question\
**Created:** [July 30, 2019, 1:54pm UTC](https://discourse.julialang.org/t/read-and-write-save-3-d-image/26978 "2019-07-30T13:54:45Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yoshua](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yoshua/32/8872_2.png) [@Yoshua](https://discourse.julialang.org/u/Yoshua)\
**Post date:** [July 30, 2019, 1:54pm UTC](https://discourse.julialang.org/t/read-and-write-save-3-d-image/26978/1 "2019-07-30T13:54:45Z")

</div>

Hello! I have problem with image manipulation.

I want to save a 3D image array in png format.  
Also wanted to know how to plot an image with some function of ImageView or Image package.

Image encoding is RGB.

If anyone can help, thank you in advance.

---

<div class="post-metadata">

**Author:** ![tim.holy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tim.holy/32/52_2.png) [@tim.holy](https://discourse.julialang.org/u/tim.holy)\
**Post date:** [July 30, 2019, 2:14pm UTC](https://discourse.julialang.org/t/read-and-write-save-3-d-image/26978/2 "2019-07-30T14:14:37Z")

</div>

What did you try so far? All this should Just Work. PNG is a 2d format but you’ll get a sequence of images when you save it.

---

<div class="post-metadata">

**Author:** ![Yoshua](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yoshua/32/8872_2.png) [@Yoshua](https://discourse.julialang.org/u/Yoshua)\
**Post date:** [July 30, 2019, 2:34pm UTC](https://discourse.julialang.org/t/read-and-write-save-3-d-image/26978/3 "2019-07-30T14:34:52Z")

</div>

what I am trying to do is this:  
save(“rgb.png”, img)  
but, that gives error.

Also, i tried to imgshow to show the image, but gives the same error.

---

<div class="post-metadata">

**Author:** ![tim.holy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tim.holy/32/52_2.png) [@tim.holy](https://discourse.julialang.org/u/tim.holy)\
**Post date:** [July 30, 2019, 6:18pm UTC](https://discourse.julialang.org/t/read-and-write-save-3-d-image/26978/4 "2019-07-30T18:18:15Z")

</div>

```julia
julia> using Colors, FileIO, ImageView

julia> img = rand(RGB, 200, 200, 5);

julia> imshow(img) # just works
Dict{String,Any} with 4 entries:
  "gui" => Dict{String,Any}("window"=>GtkWindowLeaf(name="", parent, wi…
  "roi" => Dict{String,Any}("redraw"=>68: "map(clim-mapped image, input…
  "annotations" => 4: "input-3" = Dict{UInt64,Any}() Dict{UInt64,Any} 
  "clim" => 3: "CLim" = CLim{RGB{Float64}}(RGB{Float64}(0.0,0.0,0.0), RG…

julia> save("/tmp/img.png", img) # results in 5 files, one per frame

```

---

<div class="post-metadata">

**Author:** ![Yoshua](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yoshua/32/8872_2.png) [@Yoshua](https://discourse.julialang.org/u/Yoshua)\
**Post date:** [September 2, 2019, 9:15pm UTC](https://discourse.julialang.org/t/read-and-write-save-3-d-image/26978/5 "2019-09-02T21:15:30Z")

</div>

I @tim.holy have any change in save() function to png format? It’s giving error = “save not defined”!!! I just do “using FileIO” , but the error continues.

---

<div class="post-metadata">

**Author:** ![purplishrock](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/purplishrock/32/13451_2.png) [@purplishrock](https://discourse.julialang.org/u/purplishrock)\
**Post date:** [September 2, 2019, 9:50pm UTC](https://discourse.julialang.org/t/read-and-write-save-3-d-image/26978/6 "2019-09-02T21:50:33Z")

</div>

i just tried Tim’s code and it works. However there are a lot of external package dependencies. However, “the error continues” is not particularly helpful, please read the following and provide some more detail. My guess is that you have a package configuration problem of some sort, or even a missing package.

> [@Please read: make it easier to help you](https://discourse.julialang.org/t/psa-make-it-easier-to-help-you/14757/1):
>
> 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 …
