Makie.jl
Makie.jl copied to clipboard
wglmakie saved html file is too large when color is an image
The following is just 419 KB, however if the color is changed by earth_img then the final size is 57 MB 😱.
I remember seeing something similar some months ago and at some point @SimonDanisch did some magic, probably there is a regression now 🤷🏼♂️
using WGLMakie, JSServe
using Downloads, FileIO
WGLMakie.activate!()
earth_img = load(Downloads.download("https://upload.wikimedia.org/wikipedia/commons/5/56/Blue_Marble_Next_Generation_%2B_topography_%2B_bathymetry.jpg"))
page = Page(offline=true, exportable=true)
app = JSServe.App() do session::Session
fig = mesh(Sphere(Point3f(0),1), color = earth_img, #:dodgerblue,
figure = (; resolution = (1600,800),
backgroundcolor = :black), shading=true,
lightposition = Vec3f(2, 0, 0), ambient = Vec3f(0.1, 0.3, 0.2),
#backlight = 1.0f0
)
return JSServe.record_states(session, DOM.div(fig))
end
open("MWE.html", "w") do io
println(io, """
<head>
</head>
<body>
""")
show(io, MIME"text/html"(), page)
show(io, MIME"text/html"(), app)
println(io, """
</body>
</html>
""")
end
pkg> st WGLMakie JSServe Downloads FileIO
Status `~/Documents/Project.toml`
[5789e2e9] FileIO v1.14.0
[824d6782] JSServe v1.2.7
[276b4fcb] WGLMakie v0.6.12
[f43a241f] Downloads
EDIT: It looks like this is the way it is because the image is too large. But still, I wonder if is possible to have a smaller file.
What do you mean by if the color is changed by earth_img? I don't see something like that in the code?
Or do you just mean, to actually pass earth_img as color?
yes, pass earth_img as color. Just as it is.