defold-screenshot icon indicating copy to clipboard operation
defold-screenshot copied to clipboard

Add encoding to JPEG

Open ivolff opened this issue 2 years ago • 5 comments

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 avatar Dec 16 '22 13:12 ivolff

@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

britzl avatar Dec 19 '22 10:12 britzl

No, I don't have specific proposals. But what you found looks nice and elegant enough.

ivolff avatar Dec 20 '22 10:12 ivolff

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.

aglitchman avatar Dec 26 '22 21:12 aglitchman

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.

ivolff avatar Dec 31 '22 17:12 ivolff

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?

britzl avatar Jan 01 '23 15:01 britzl