Voxelmanip Forums
Compa Compa
please just get off the internet already jamie
Posted on 2022-07-01 09:15 (edited 2022-07-01 09:17) Link | ID: 101
Seriously, I thought everything was in place a few years ago:

- Serve JPEGs for photographs, GIFs for animations, PNGs for things that require transparency or for graphics
- Serve MP4/H.264 video and provide a means of easily downloading the file in another format if otherwise not possible
- Serve OGG for audio.

Suddenly, it seems like we're in Format Hell once again... 4chan and some Linux users seem to really like WebM/VP9, everyone else in the fucking world uses MP4/AVC.

(There's some history behind this too: it relates to the removal of a codec specification from the HTML5 standard back in 2007, mostly because Apple cried about digital restrictions management.)

Of course, it's Apple's fault for being wankers and not supporting open formats, mostly to try to frustrate non-iTunes users (or those attempting to migrate from it): in a pretty sad state of affairs, the FLAC standard is under a BSD licence and Apple could so easily implement it but they don't because they changed two things in it to support DRM and called it ALAC. (Don't get me fucking started on how obtuse they were about OGG/OGV).

Personally, I'd like to see more things effectively tell Apple users to shove their I-Devices up their arse to the point that people begin to switch to Android by ignoring any and all demands that the company make and pay international bodies like the EU to turn a blind eye towards; though, the most recent bunch of bullshit has come from Google suddenly pushing the loosely-related-to-WebM-but-not-quite-the-same-thing out of the blue, despite it existing for ten years already and coming out around the same time, and virtually having no real reason to exist when everyone knew exactly WHAT to use a JPEG and a PNG and a GIF and an SVG for... yes, I'm talking about WebP.

Seriously, as if WebM wasn't pointless enough, we now also have to deal with WebP everywhere. I noticed this format's existence around 2016 when trying to save some avatars in Discord and just assumed it was something related to Electron, but alas, Google has suddenly decided they will start lobbying everyone and now trying to save anything will fucking save it in WebP format. And no, renaming the thing does not work, at least on some formats. But seriously, what's the point? La-dele-de, something-something alpha channel, compression, bollocks... You had ten years to push this shit on people and you do it now just to piss people off when they try to save an image. Feels more like some kind of patent avoidance more than anything else (or because four letter+ file extensions are all the rage these days).
ROllerozxa ROllerozxa
Site Admin
Posted on 2022-07-01 11:20 (edited 2022-07-01 11:37) Link | ID: 102
I'm just gonna go out and say that WEBP is literal Google propaganda and I hate it.

Essentially it's a single image encoded like it's a video file, and it can be either lossless (PNG-esque) or lossy (JPEG-esque). It can have an alpha channel in either case (lossy transparency... yuck) and I think even animated (...well that would just turn them into WEBMs wouldn't they, and that's a completely different can of worms).

So, WEBP could replace essentially all image formats on the web just with that. But Google also claims that these image files have significantly better compression rates than the other file formats. This is a whole load of bullshit and clever marketing swayed in favour of WEBP.

For PNG, Google cherrypicks an optimal WEBP filesize and pits that against a subparly optimised PNG file, claiming an about ~25% filesize reduction. Meanwhile, if you were to aggressively optimise PNG files with the optimal optipng arguments (like we in the Minetest community do), you could see that a PNG is essentially just a handful of bytes larger than a WEBP. Nothing anyone honestly should worry about.

For JPEG, Google uses cjpeg as part of the reference JPEG specification, and claims lossy WEBPs beat a JPEG at the same quality level at up to 34% reduction of the image size. Thing is, the reference implementation write pretty shoddily encoded images (they're perfectly fine, just the filesize is larger than they could be). And there is this thing called mozjpeg which offers significantly better compression ratio for encoding images using the JPEG format. You could just feed your poorly encoded JPEG images into that and reduce the filesize similar to optimising PNG images with optipng, and like magic it now becomes more or less the same size as an equivalent WEBP.

When all that propaganda is thrown away, you're left with a slightly less supported PNG/JPEG format. No real filesize wins to be had, people will usually need to provide both WEBP and PNG/JPEG as a fallback which leads to having to develop such a pipeline for assets and effectively doubling the size of your images being stored.

In reality, you could just run optimisers on the existing formats to shave off filesizes for everyone (image editors save A LOT of useless junk and may also have a lower compression ratio to make it faster. A typical 16x16 texture saved to PNG with GIMP with default settings is 4-5k. optipng brings that down to a mere hundred bytes usually).

However in WEBP's defense, it has actually gained pretty much widespread adoption that it's become slightly easier to deal with them. E.g. Gwenview can view WEBP images and GIMP can edit, save and convert them. I'm honestly more pissed over places like Wikia/Fandom converting all their uploaded PNG images into lossy WEBP images, destroying things like pixelated texture images in the process.

I could probably go on about other formats... how GIF is essentially a dead format nowadays due to its colour limitations and large filesize, most "GIF"s you see are in reality looped mp4 or WEBM files (or even an animated PNG image), or what the deal with WEBM is compared to mp4 and why any mp4 files I try to convert into WEBM with ffmpeg turns into low-bitrate blobby goo, and all the other "video-format-as-image-format"s that have popped up (HEIC, AVIF...). But that can probably wait for another post.

For all intents and purposes, a stack of well optimised (a)PNG, JPEG and SVG images should fit well enough for any website. Video I don't know, but I'd be gravitating towards just mp4.
luatic luatic
Posted on 2022-07-01 13:04 Link | ID: 106
I'm gonna approach this from a dev perspective: I like the PNG spec because it's simple enough. I've written a full-fledged PNG reader in Lua; a simple writer that just spits out ARGB8 and then feeds that to zlib is also very easy to implement.

In addition, PNG uses a bunch of CRC32 checksums; you could in theory transmit PNG over the wire raw using UDP or the like - no need for error detection on top, you can already use the PNG CRCs. Furthermore PNG consists of streamable chunks. Can the same be said about WEBP? I feel the comparison might be unfair because WEBP probably doesn't "waste" a couple bytes on error detection.
Compa Compa
please just get off the internet already jamie
Posted on 2022-07-01 18:02 (edited 2022-07-01 18:05) Link | ID: 111
Can WEBP store extended metadata like camera-related information the way a JPEG can? (I'm fairly sure a PNG doesn't officially support extended metadata, even if one was to hack it into the file, I imagine support for it in image viewers and whatnot would be patchy.)

Also, I find it extremely weird that they only just decided to push it, given they had ten fucking years to push for it. They already pushed WEBM (or tried to) years ago, and the hilariously miniscule amount of adopters seem to be entirely confined to 4chan (and Reddit reposts).

@ROllerozxa

Transcoding one lossy codec into another will lessen the quality for obvious reasons.

Honestly the only reason WebM/WebP even seem to exist are related to patents held on the H.264 codec when used commercially, which funny enough is a problem for very few people anyways unless you're Stallman-tier paranoid about things.
Coromax Coromax
Posted on 2022-07-01 21:55 Link | ID: 119
WebP irritates me to no end.

Whenever I want to download an image off google images, oftentimes it only gives me the option of WebP.

Do I really need to spend time converting some shitty format just to view the image? It isn't even industry standard, like PNGs, JPEGs and GIFs, which are the formats I expect to be served.

WebM seems to be better supported in my experience, but I still encounter issues with it from time to time. I'm still waiting to find someone aside from 4channers, elgoog and redditors who really like the those formats, since I genuinely haven't found any good reason to use those over the standard formats like MP4, PNG and JPEG, which just works as it should. Whatever happened to making stuff easy to access? -_-
Compa Compa
please just get off the internet already jamie
Posted on 2022-07-02 10:30 Link | ID: 123
Whatever happened to making stuff easy to access?
2016 happened.
luatic luatic
Posted on 2022-07-02 16:29 (edited 2022-07-02 16:59) Link | ID: 129
Can WEBP store extended metadata like camera-related information the way a JPEG can? (I'm fairly sure a PNG doesn't officially support extended metadata, even if one was to hack it into the file, I imagine support for it in image viewers and whatnot would be patchy.)
1. PNGs do officially support arbitrary ancillary chunks, so extend as you wish ;) (just keep in mind that most viewers will probably happily ignore them)
2. There are multiple predefined ancillary chunks for storing textual information
Compa Compa
please just get off the internet already jamie
Posted on 2022-07-02 22:53 Link | ID: 132
Oh, that's interesting. Dunno if I'd go as far as storing a photograph as a PNG though, I mean, JPEG is optimised for photographs and printing aforementioned photographs...
ROllerozxa ROllerozxa
Site Admin
Posted on 2022-07-15 16:10 Link | ID: 231
Just found out ffmpeg not only works with audio and video but also images... So it can quickly convert Webp to a PNG or a JPEG depending on the output extension you give it, just like how you can quickly convert between video and audio formats by relying on ffmpeg usually being smart enough to detect from file extension!

ffmpeg -i <image>.webp <image>.png

Another point for ffmpeg being the Swiss army knife of multimedia manipulation from the command-line, Imagemagick beware.
Compa Compa
please just get off the internet already jamie
Posted on 2022-07-15 16:47 Link | ID: 235
Oh that's really handy to know, thanks! It's also unsurprising it can work with images since I've used ffmpeg's loop function to effectively put audio and an image into a YouTube-ready video and the filesize is barely more than the audio usually. :D
ROllerozxa ROllerozxa
Site Admin
Posted on 2022-07-15 17:10 Link | ID: 239
Oh yeah that is pretty cool too, I've actually done that for making music videos, combining an audio file and a static image into a video. It's a whole lot easier and faster than opening up Kdenlive and making it there especially when doing an entire soundtrack in bulk.

In fact, I think this even deserves an entire thread just talking about ffmpeg. :D