defold-screenshot
defold-screenshot copied to clipboard
Add encoding to JPEG
For some cases PNG is too huge. So there would be cool if we can encode screenshots or given PNG to JPEG (perfectly with various rate of compression)
@ivolff sure, jpeg could be an addition for sure. Do you have any recommendation for a small JPEG encoder? I did a quick search and found one, but there are probably others?
https://github.com/serge-rgb/TinyJPEG/blob/master/tiny_jpeg.h
No, I don't have specific proposals. But what you found looks nice and elegant enough.
I think that the main requirement for the JPEG encoder should be encoding speed, not its binary size.
That's the reason why I proposed the fpng
encoder for PNGs: LodePNG was taking 1-2 seconds to encode a QHD or 4K screenshot on a high-end PC. fpng
does the same less than for 0.1 sec.
hm, for me this is not significant cause such operations is not some "daily" action, it happense once-twice per session. In this case we can pause the game or make this async.
I see this usecases: Aniway for cases where we need fast snapshot something we can use PNG.
And in cases where we want to comress something probably next we will do some not to fast operations like write in disk of send to server bu http (my case). In this case speed is not to important unlike a file size.
That's the reason why I proposed the
fpng
encoder for PNGs: LodePNG was taking 1-2 seconds to encode a QHD or 4K screenshot on a high-end PC.fpng
does the same less than for 0.1 sec
I think we want to strike a balance between binary size of the extension and compression speed. I haven't looked into any if this myself and will happily accept pull requests.
One thing to consider is if the screenshot extension should support multiple image formats or if it is better to only support raw pixels and png and for those users who want other image formats instead offer image compression extensions?