Offline site encoded AVIF workaround

For support with specific websites

Moderator: trava90

Forum rules
Please always mention the name/domain of the website in question in your topic title.
Please one website per topic thread (to help keep things organized). While behavior on different sites might at first glance seem similar, they are not necessarily caused by the same.

Please try to include any relevant output from the Toolkit Error Console or the Developer Tools Web Console using the following procedure:
  1. Clear any current output
  2. Navigate or refresh the page in question
  3. Copy and paste Errors or seemingly relevant Warnings into a single [ code ] block.
User avatar
Deadgye
Hobby Astronomer
Hobby Astronomer
Posts: 26
Joined: 2020-11-06, 23:59

Offline site encoded AVIF workaround

Post by Deadgye » 2025-06-05, 21:47

I sometimes procrastinate with CYOA games. In recent years its become popular to create interactive versions that are hosted on sites like neocities. These interactive CYOA sites are more annoying to save than sets of images, but they can often be saved without too much extra effort.

It's common for these interactive sites to store their images directly in their javascript code. E.g.:

Code: Select all

"image":"data:image/avif;base64,blahBlahBlahBlahBlah",
And as you can see from the example, some creators have started converting their images to AVIF format. I assume because someone shared an easy to use utility that mass converts & compresses all images in an interactive CYOA to WEBP (and now AVIF) format.

I'm thus unable to view these sites in Pale Moon, as none of the AVIF images load. However, since I intend to save these sites and view them offline anyway, I'm very much open to working around this issue by converting these images back into a supported format.
I figure I can throw together something, maybe a tiny python script, to parse these embedded AVIF images and convert them. The Base64 decode and eventual re-encode should be simple enough. But how to perform the actual format conversion is where I'm a bit lost and would appreciate recommendations. I'm guessing I should convert them into JPEG-XL format, since I'd have no way to know if the images were originally JPG or PNG. (And to give AVIF the metaphorical middle finger.)
But what can I use to convert the AVIF string into a JPEG-XL string? (Also, to make things harder, whatever I use / do would need to work on win7.)

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 37765
Joined: 2011-08-28, 17:27
Location: Motala, SE

Re: Offline site encoded AVIF workaround

Post by Moonchild » 2025-06-05, 22:20

You could use imagemagick - they provide Windows binaries AFAIK. For JXL you may need an additional download but that should be easy enough.

As an aside I'm not sure why they chose AVIF if file size is their main concern (it should be if base64 embedded) since it's notoriously not very good at small filesizes.
"A dead end street is a place to turn around and go into a new direction" - Anonymous
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite

User avatar
Gemmaugr
Fanatic
Fanatic
Posts: 148
Joined: 2025-02-03, 07:55

Re: Offline site encoded AVIF workaround

Post by Gemmaugr » 2025-06-05, 22:29

Found lots of online conversion sites, but only one of them without any third party fluff: https://www.jpegxl.io/

vannilla
Moon Magic practitioner
Moon Magic practitioner
Posts: 2415
Joined: 2018-05-05, 13:29

Re: Offline site encoded AVIF workaround

Post by vannilla » 2025-06-06, 00:34

Which system are you on?
With ffmpeg it's trivial, it handles data: URIs natively too so you don't even need to parse the base64 string, but I don't know its status outside Linux.

After posting edit: I missed the parenthetical at the end of the post (I'm blind :lol: ) but I'm going to keep this answer as-is for anyone looking for something similar. :angel:

User avatar
adoxa
Lunatic
Lunatic
Posts: 437
Joined: 2019-03-16, 13:26
Location: Qld, Aus.

Re: Offline site encoded AVIF workaround

Post by adoxa » 2025-06-06, 01:15

Gemmaugr wrote:
2025-06-05, 22:29
Found lots of online conversion sites, but only one of them without any third party fluff: https://www.jpegxl.io/
I don't know about that site - it says "No data is sent. The magic happens in your browser.", but it uploads to 176.223.132.38 and there's no wasm.

There are Windows builds of FFmpeg, but I'm not sure if the essentials build (that supports Win7) would support AVIF; you do need the full build (which doesn't support 7) for JPEG-XL. Alternatively, this says it supports 7 (it didn't work on my virtual 7, but I didn't install the UCRT).

User avatar
Deadgye
Hobby Astronomer
Hobby Astronomer
Posts: 26
Joined: 2020-11-06, 23:59

Re: Offline site encoded AVIF workaround

Post by Deadgye » 2025-06-06, 15:17

Thanks for the suggestions!
I figured Win7 vs AVIF / JPEG-XL would probably be the more annoying part of the workaround. I'll give ImageMagick a try first. The latest windows portable version printed out the help text instead of crashing, which is a good sign. If that fails, I'll check out that alt build of ffmpeg. I've used ffmpeg for stuff in the past, but the build I have is from 2014 or earlier so I doubt it'd handle the newer formats.
Moonchild wrote:
2025-06-05, 22:20
As an aside I'm not sure why they chose AVIF if file size is their main concern (it should be if base64 embedded) since it's notoriously not very good at small filesizes.
It looks like the Interactive CYOA Creator tool people made and shared supports an optional feature to "automatically converts PNG or JPEG files larger than 500KB to WebP format upon set Choce/Row images.", and so this AVIF-CYOA-compressor tool was a misguided improvement over that.