godot-docs icon indicating copy to clipboard operation
godot-docs copied to clipboard

Consider using an image format other than PNG

Open Jayman2000 opened this issue 3 years ago • 1 comments
trafficstars

Your Godot version: N/A

Issue description: At the moment, the doc writing guidelines say

Before you add or replace any images in the documentation, they should be run through a PNG compressor to save size. You can use the lossless OxiPNG compressor included in Squoosh for this purpose. For heavier images, consider using a lossy compressor like pngquant. With it, almost no image quality is lost during compression.

In my experience, lossless WebPs tend to be smaller than PNGs. I wrote a Bash script that converts all of the images in this repo to lossless WebPs. On my system, all of the PNG files take up 49MiB of space. Once you convert them to lossless WebPs, they take up 36MiB of space. We could probably save even more space by making some of the images lossy WebPs or AVIF files.

I’m not sure if PDF or EPUB files support these newer image formats, so it might make sense to keep the source files as PNGs and then convert them to another format when building the HTML documentation.

URL to the documentation page (if already existing): https://docs.godotengine.org/en/latest/community/contributing/docs_writing_guidelines.html#image-contribution-guidelines

Jayman2000 avatar Sep 13 '22 18:09 Jayman2000

I've been thinking about this recently. I agree with moving towards WebP (both for lossless and lossy images when lossless is too large).

An alternative is to use lossy PNG compression with pngquant for the largest PNG images we currently have (those with a size greater than 250 KB or so). If you run oxipng --strip --zopfli on the output PNGs, you can get to a pretty low size with only a small decrease in quality (and no JPEG artifacts or generation loss).

As of September 2022, AVIF support is still missing in Edge and Safari (before macOS Ventura), so I wouldn't use AVIF yet.

I’m not sure if PDF or EPUB files support these newer image formats, so it might make sense to keep the source files as PNGs and then convert them to another format when building the HTML documentation.

We don't distribute PDF or EPUB builds of the documentation. I'm not sure how many people build those formats from source when they can download precompiled HTML builds. Despite all the legacy of PDF and EPUB, HTML is typically the better format for reading on computers or mobile devices :slightly_smiling_face:

Calinou avatar Sep 13 '22 20:09 Calinou

I greatly support this. For at least a year or so, whenever some1 told me that .webp is more efficient than .jpg, I would disagree because in all my use-cases it wasn't the case, as .jpg in low compression achieves size near .webp

For this https://github.com/godotengine/godot-docs/pull/6243 however, exporting lossless images (.png printed from my screen) to quality 80 of .webp (and no alpha channel), the difference in size is obvious, its like 40% smaller than .jpg of same visual quality

We don't distribute PDF or EPUB builds of the documentation. I'm not sure how many people build those formats from source when they can download precompiled HTML builds. Despite all the legacy of PDF and EPUB, HTML is typically the better format for reading on computers or mobile devices

I agree, the HTML format is too good to also have .pdf You can also build the docs and have them offline too from what I remember

TheYellowArchitect avatar Sep 29 '22 14:09 TheYellowArchitect

As someone who has updated more images for this documentation than I can count I'm in full agreement with moving to webp. Lossy compression would be one less thing I and everyone else would need to do when updating images. And we could always then move to avif at a later date.

skyace65 avatar Oct 04 '22 02:10 skyace65

If I interpret https://caniuse.com/webp correctly, all current major browser support WebP. I've been using WebP heavily with Chrome and Firefox at least for other stuff for multiple years now and encountered no issues and have observed similar wins for perf/size reduction.

We may indeed just want to move to WebP (at least for now).

mhilbrunner avatar Oct 04 '22 11:10 mhilbrunner