How to set the output size in `savefig()` in `GR.jl`

182 Views Asked by At

I have a simple question about using GR.jl directly (Not using Plots.jl).
I am displaying an image of size 300x300.

I want to display it on screen and save the plot with savefig:

using GR

img = rand(300, 300)

imshow(img)

savefig("img.png")

I expect the output to have size of 300x300 yet I get much bigger size.

How can I control the output size?

I saw https://github.com/JuliaPlots/Plots.jl/issues/2303 yet I am not sure if it is related.

1

There are 1 best solutions below

0
Bill On

savefig("img.png", height = 300, width = 300) should produce the correct size PNG. For further modifications you can use the functions in the Images package on your img prior to writing to file.