JosefNemec / Playnite

Video game library manager with support for wide range of 3rd party libraries and game emulation support, providing one unified interface for your games.
https://playnite.link
MIT License
9.58k stars 508 forks source link

Add AVIF image format support to dialogs #3560

Open darklinkpower opened 1 year ago

darklinkpower commented 1 year ago

Feature description

Add support to select and drag and drop images in this format in the different dialogs, in the same way support for webp was added in the past.

AVIF is a newer image format that offers better size-quality relation than even webp on top of more features. Source: https://avif.io/blog/comparisons/avif-vs-webp/

It needs to be noted that this format is not supported by default on Windows and in the same way that the Webp Image Extensions needs to be installed on systems that do not support it, there's an extension available to add system-wide support for the format here: AV1 Video Extension

After installing this extension, the format will work in Playnite without any issues.

Screenshots

Example of AVIF image being displayed on Playnite after installing AV1 Video Extension:

image

Test image (Extension renamed to jpg for testing, original extension is avif. Also available here):

44ffbd12-6327-436b-9a5c-32e83a5b3310

Lossless formats size comparison:

image

darklinkpower commented 1 year ago

I had curiosity so I made some tests and wanted to share some findings of different image formats (assuming my test was error-free) when used in Playnite for anyone that might find it useful. It looks like loading and decoding AVIF images takes a much longer than PNGs and JPGs so it might not be a good idea to use in covers, though they're still faster than WebP. This of course will vary from system to system, mine is an old 4 cores laptop.

I ran a test of loading and decoding images 100 times, specifically using the BitmapExtensions.BitmapFromFile() method.

1920x1080 px resolution Image Time (seconds) Average (seconds)
avif_lossless.avif 52.2377621 0.522377621
avif_lossy.avif 18.3624145 0.183624145
jpg.jpg 2.289814 0.02289814
png.png 7.6258898 0.076258898
webp_lossless.webp 185.399797 1.85399797
webp_lossy.webp 67.8383601 0.678383601

imgtest.zip

600x900 px resolution

Image Time (seconds) Average (seconds)
avif_lossless.avif 15.2070376 0.152070376
avif_lossy.avif 8.4947385 0.084947385
jpg.jpg 0.8941672 0.008941672
png.png 1.8583103 0.018583103
webp_lossless.webp 66.2192944 0.662192944
webp_lossy.webp 54.2617363 0.542617363

covers.zip

JosefNemec commented 1 year ago

Half a second for an image is pretty slow, even on older CPU, but not that surprising if it needs to use that external decoder.

It should be noticeably faster in P11 with Avalonia since that one is using Skia's image decoding as far as I know.

darklinkpower commented 1 year ago

It should be noticeably faster in P11 with Avalonia since that one is using Skia's image decoding as far as I know.

That's great news. The whole topic of modern image formats is a very interesting one, with aspects like encoding and decoding speed, compression efficiency, quality as well as their features. I looked it up and apparently they don't support jpeg XL yet (another modern format, possibly even better than AVIF) but it will be great to be able to use new formats efficiently in Playnite.