Open murlakatamenka opened 7 months ago
I actually wouldn't mind making this a default. This sounds like a good FR. Is there any way we can natively implement this optimization set using just the image crate? I'd prefer not expanding the dependency graph unless needed.
So far I don't think you can avoid pulling oxipng
as a dependency.
Seeing your positive reaction I'll work on PR, we'll see how it goes there.
That sounds great, I wouldn't mind a PR for further discussion.
png by default is a reasonable choice. However, it's surely doesn't offer the best compression as of today. For instance, lossless webp consistently beats png in terms of compression ratio.
I suggest adding a separate flag to optimize png output via awesome
oxipng
crate, something like:It is easy via
oxipng::optimize_from_memory
:Here is a little script to evaluate the savings:
Results for a sample image (
2560x1080
, 414 KiB) on Ryzen 5600:oxipng 9.0
Pretty good imo, and using oxipng from Rust itself will be even faster (no CLI args parsing, no buffer copy).
Reasonable tradeoff of little extra CPU for decent savings in file size even with fast-ish presets 0-2.
Surely I can do the plumbing myself,
wayshot --stdout | <best-image-encoder> - <name.ext>
, but I think wayshot and its users will benefit from implementing this feature.