# Makie consistency problem in iteratively saved png resolution

**URL:** <https://discourse.julialang.org/t/makie-consistency-problem-in-iteratively-saved-png-resolution/52582>\
**Category:** New to Julia\
**Tags:** plotting\
**Created:** [December 29, 2020, 6:18pm UTC](https://discourse.julialang.org/t/makie-consistency-problem-in-iteratively-saved-png-resolution/52582 "2020-12-29T18:18:23Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![YohanSassi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yohansassi/32/20583_2.png) [@YohanSassi](https://discourse.julialang.org/u/YohanSassi)\
**Post date:** [December 29, 2020, 6:18pm UTC](https://discourse.julialang.org/t/makie-consistency-problem-in-iteratively-saved-png-resolution/52582/1 "2020-12-29T18:18:23Z")

</div>

Hi all,

In the following MWE there is a problem of resolution consistency when saving iteratively png from a Makie scene:

```julia
using GLMakie,AbstractPlotting,ImageCore
function save_png(img, i)
    fn=string(i)*".png"
    scene = AbstractPlotting.image(rotr90(img), show_axis = false);
    AbstractPlotting.save(fn, scene; resolution = (1920,1088), px_per_unit = 72)
    close(GLMakie.global_gl_screen())
    nothing
end

function res_png(nf)
    nx,ny=1920,1088

    for i=1:nf
        img = rand(RGB{N0f8}, nx, ny)
        save_png(img,i)
        println("Saved png resolution :", size(load(string(i,".png"))))
    end
end
res_png(100)

```

I would like all the saved png to have the same resolution: 1920,1088 as specified when calling the save function. Any ideas?

Thanks in advance for the time you will take to help me.

---

<div class="post-metadata">

**Author:** ![contradict](https://avatars.discourse-cdn.com/v4/letter/c/ac91a4/32.png) [@contradict](https://discourse.julialang.org/u/contradict)\
**Post date:** [December 29, 2020, 6:44pm UTC](https://discourse.julialang.org/t/makie-consistency-problem-in-iteratively-saved-png-resolution/52582/2 "2020-12-29T18:44:11Z")

</div>

I suspect you have some other packages loaded, the set of packages in your `using` statement does not provide a `load` method. Replacing `ImageCore` with `Images` produces:

```julia
Saved png resolution :(1088, 1920)
Saved png resolution :(1088, 1920)
Saved png resolution :(1088, 1920)
Saved png resolution :(1088, 1920)
Saved png resolution :(1088, 1920)
.
.
.

```

Which looks like it is working to me.

---

<div class="post-metadata">

**Author:** ![YohanSassi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yohansassi/32/20583_2.png) [@YohanSassi](https://discourse.julialang.org/u/YohanSassi)\
**Post date:** [January 6, 2021, 1:07pm UTC](https://discourse.julialang.org/t/makie-consistency-problem-in-iteratively-saved-png-resolution/52582/4 "2021-01-06T13:07:46Z")

</div>

@contradict, I though it was resolved… But actually it’s not the case. I rewrote a MWE, this time with a video as it’s closer to what I would like to do.

```julia
using VideoIO, FileIO
using GLMakie,AbstractPlotting

function save_png(img, i,rota)
    fn=string(i)*".png"
    scene = AbstractPlotting.image(rotr90(img), show_axis = false);
    AbstractPlotting.rotate!(scene,-rota)
    AbstractPlotting.save(fn, scene; resolution = (1920,1088), px_per_unit = 72)
    close(GLMakie.global_gl_screen())
    nothing
end

function ext_frames(vid_name::String, rota)
    io = VideoIO.testvideo(vid_name) # for testing purposes
    f = VideoIO.openvideo(io); ## Open the video
    img = read(f); ## Take the first frame
    n = 1
    save_png(img,n,rota)

    while !eof(f) ## While the video is not finished
        next_img = read!(f, img); ## Take the next frame
        n = n + 1
        save_png(next_img,n,rota)
        println("Saved png resolution :", size(load(string(n,".png"))))
    end
    close(f)
end

ext_frames("annie_oakley", pi/67)

```

I tried 3 times in a row, each time destroying my REPL in between. The first time it worked well until the 611th frames, at this time 16 consecutive frames were saved with a resolution of 2176, 3840 (my screen). This happened again at the 704th frames. The 2nd try worked properly. However, the third time I had again the same problems, after the 524th, 618th and 611th frames the 16 next were saved with a different resolution than the 1088,1920 asked.

Why I have this changes in resolution and how to fix it? And how to speed up the process ? And why this is so random?

Thanks in advance for the time you will take to look into it.

---

<div class="post-metadata">

**Author:** ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)\
**Post date:** [January 6, 2021, 1:39pm UTC](https://discourse.julialang.org/t/makie-consistency-problem-in-iteratively-saved-png-resolution/52582/5 "2021-01-06T13:39:27Z")

</div>

What OS is this? This is likely some weird OS window manager problem. Do you get an open window? Is this in the VSCode/Atom repl?

---

<div class="post-metadata">

**Author:** ![YohanSassi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yohansassi/32/20583_2.png) [@YohanSassi](https://discourse.julialang.org/u/YohanSassi)\
**Post date:** [January 6, 2021, 1:49pm UTC](https://discourse.julialang.org/t/makie-consistency-problem-in-iteratively-saved-png-resolution/52582/6 "2021-01-06T13:49:14Z")

</div>

I’m working on macOS Big Sur 11.1. Indeed when the script is running I have an open window (exe).  
It’s on VSCode v1.52.1.

---

<div class="post-metadata">

**Author:** ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)\
**Post date:** [January 6, 2021, 1:55pm UTC](https://discourse.julialang.org/t/makie-consistency-problem-in-iteratively-saved-png-resolution/52582/7 "2021-01-06T13:55:40Z")

</div>

> [@YohanSassi](#):
>
> I’m working on macOS Big Sur 11.1. Indeed when the script is running I have an open window (exe).

Sigh, MacOS of course…  
Open window + MacOS + VSCode is probably the worst combination for this kind of problem 😃  
Can you try a clean REPL, with a hidden window?  
`AbstractPlotting.inline!(true)` in the beginning of the script should make `save(scene, "..")` not open any window.

---

<div class="post-metadata">

**Author:** ![YohanSassi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yohansassi/32/20583_2.png) [@YohanSassi](https://discourse.julialang.org/u/YohanSassi)\
**Post date:** [January 6, 2021, 2:12pm UTC](https://discourse.julialang.org/t/makie-consistency-problem-in-iteratively-saved-png-resolution/52582/8 "2021-01-06T14:12:56Z")

</div>

Ohh that’s a bad news then…

Where exactly you want me to add `AbstractPlotting.inline!(true)` ?  
I tried right after the using, but also as the first line of the `save_png()`, it’s not solving the problem at all. The window is still opening and the resolution problem is still there…

---

<div class="post-metadata">

**Author:** ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)\
**Post date:** [January 6, 2021, 2:26pm UTC](https://discourse.julialang.org/t/makie-consistency-problem-in-iteratively-saved-png-resolution/52582/9 "2021-01-06T14:26:42Z")

</div>

Like this:

```julia
using GLMakie,AbstractPlotting,ImageCore, FileIO
AbstractPlotting.inline!(true)

function save_png(img, i)
    fn="test/$(i).png"
    scene = AbstractPlotting.image(rotr90(img), show_axis = false);
    AbstractPlotting.save(fn, scene; resolution = (1920,1088), px_per_unit = 72)
    close(GLMakie.global_gl_screen())
    nothing
end
mkdir("test")
function res_png(nf)
    nx,ny=1920,1088

    for i=1:nf
        img = rand(RGB{N0f8}, nx, ny)
        save_png(img,i)
        println("Saved png resolution :", size(load("test/$(i).png")))
    end
end
res_png(100)

```

Just tried this, and window is hidden & resolutions stay the same… Sigh, looks like another unexplainable osx bug…  
On what AbstractPlotting version are you?

---

<div class="post-metadata">

**Author:** ![YohanSassi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yohansassi/32/20583_2.png) [@YohanSassi](https://discourse.julialang.org/u/YohanSassi)\
**Post date:** [January 6, 2021, 2:46pm UTC](https://discourse.julialang.org/t/makie-consistency-problem-in-iteratively-saved-png-resolution/52582/10 "2021-01-06T14:46:33Z")

</div>

Nop, I still have the same problem… The resolution changed at the 59th image and that for the 16 following ones and then come back to the asked resolution. That’s really weird !

I’m with `AbstractPlotting v0.14.4`
