Encode previews as JPEG, WEBP, AVIF,

With both Chrome and Firefox supporting AVIF naively, this would more than halve the size of the previews directory, and make browsing over constrained networks much more pleasant.

Update: AVIF encoding is staggeringly slow, and would make imports 5-20x slower.

Mobile Safari would be left out in the cold, though, unless both JPEG and AVIF were rendered.

More info:

1 Like

That sounds like a good preference: “Should Photostructure render previews and JPEGs, AVIFs, or both” (and then an explanation of why one might choose one or the other, and a warning more drive space will be used but streaming could be more pleasant).

1 Like

For those of us that don’t use Apple products (my wife and I just use Windows PCs and Samsung phones and tablets), I wouldn’t mind an “I don’t care about Mobile Safari” option that uses newer file formats only supported by Chrome and Firefox.

1 Like

I went down this path with webp, but found that webp was much slower to encode (5-10x slower: AVIF is even worse than that!), and only reduced preview sizes by ~30%.

Voting for this as something to keep an eye on for the future, as AVIF is still being developed. JPEG XL might be a better option too.

Codec Encoding Speed (MP/s) Decoding Speed (MP/s)
JPEG (libjpeg-turbo) 49 108
HEVC (HM) 0.014 5.3
HEVC (x265) 3.7 14
JPEG XL 50 132

Source: How JPEG XL Compares to Other Image Codecs

And this: Modern Data Compression in 2021 Part 2 : The Battle to Dethrone JPEG with JPEG-XL, AVIF, and WEBP – Chips and Cheese

Thanks for sharing!

That article makes JPEG-XL look great: but literally no browser supports it (unless I’m reading this wrong):

https://caniuse.com/jpegxl

The way it handles progressive decoding might also make thumbnail generation faster and require fewer files.

ImageMagick supports JPEG XL: ImageMagick - Image Formats - needs the delegate library: jpeg / JPEG XL Reference Software · GitLab

Chromium status: 1178058 - chromium - An open-source project to help move the web forward. - Monorail - Looks like it will make an appearance in Chrome 91.

Firefox: 1707590 - Initial implementation for JXL - currently has some test failures, not sure when it will make it into a release.

JXL support is coming, but it has a few months to go.

Thanks (as always!) for doing that research: I set this topic to “auto bump” in 2 months to remind me to check it out again.

:beers:

1 Like

PhotoStructure uses sharp for image manipulation and JPEG encoding. sharp, in turn, is based on libvips, which just added JPEG XL, but support is “immature”:

1 Like

Chrome 91 now has JPEG XL as a [disabled by default] feature.

chrome://flags/#enable-jxl to enable

Someone from the images infra team at Facebook has a lot of good feedback about JPEG XL as well:

After spending the last 5 months investigating and evaluating JPEG XL from both a performance and quality point of view, it’s our opinion that JPEG XL has the most potential of the new generation of image formats that are trying to succeed JPEG.

Recent news about the jxl library being developed in public now:

(There are still a couple blockers before jxl is in sharp: but I could do reencoding with an external tool, similar to how I handle HEIF. There are serious performance downsides to that approach, though)

Looked again at the state of the art for AVIF:

and AV1:

There’s a lot more green there than the last time I checked!

Unfortunately, I still haven’t found the magick incantation necessary for ffmpeg to transcode an AV1 stream such that Chrome, Firefox, and Safari can all render it properly.

AV1 encoding is at least 5x slower to compress than MP4, but it’s a one-time cost, and reducing disk space and bandwidth is interesting.