I want to use AVIF on my XP-sites
What is AVIF?
AVIF is an image format that has much better compression then JPEG or WebP. I first learned about it from Jake Archibalds blog a few years ago.
It might make my images ~50% smaller (or more). And that will reduce the size of my webpages significantly. And make them perform much better.
It also has good enough browser support, that I think it’s about time to start using it.
No Java-support
There doesn’t seem to be any Java-support for AVIF, and that means no XP-support for it.
Workaround
Use an external transcoder, and cache the result in a repo.
Step-by-step walktrough of workaround
This is how I’m thinking to build it:
First I need to setup a transcoder service running on AWS Lambda or similar. It takes in an HTTP POST with an image, and similar parameters as portalLib.imageUrl()
, and returns the transcoded image.
(Alternatively I could get a subscription to an existing service like cloudinary).
Then I create an XP-service that does the following:
- Use
routerLib
to be able to parse a url similar to the one that the image-service in XP creates- It takes in the size and id of an image in XP
- Use
nodeLib
to check if I have a stored AVIF-version of that image with that size and return it - If no image
- Start a
Task
that useshttpClientLib
against the transcoder service to get an AVIF-image that can be stored as binary usingnodeLib
. - Immediately return a redirect to a JPG-version of the image.
- Start a
Questions
- Has anyone done anything similar?
- Or do you have an even better way to do this?
- Are you using something like cloudinary?
- Do you want to join in building an open source version of this?