-
☭民兵
Hey, mates. I know that XMPP standard supports user to use avatar in any kind of formats. But I wonder the formats that most of developers approve. Personally, I love WebP>SVG>PNG; JPEG and AVIF are mediocre in my view; others like jpx, gif, I will not consider them. But, for client software, bad SVG consumes much RAM, and AVIF always consumes much CPU, so they may be inconvenient or even dangerous, I guess? Others mentioned above would be safe unless some pictures being loaded are too large (either in resolution or file size). What are your opinions?
-
Menel
Picture too large is not an issue with the max stanza size currently
-
Link Mauve
☭民兵, for avatars explicitly, XEP-0084 requires it to be present in PNG, with additional nodes in different formats if this is wanted.
-
Link Mauve
I would say SVG rendering is more CPU bound than AVIF or other bitmap formats, especially when using filters.
-
Link Mauve
But it has the very useful property of being a vector format, so it can be rendered at any size.
-
Link Mauve
Also AVIF usually uses the video decoder hardware for decoding, thus completely freeing the CPU while decoding happens.
-
☭民兵
Thank you for telling me that.
-
Menel
I've never seen avif in the wild yet, do clients support that?
-
☭民兵
I do not care about this situation. I guess very less people know and use AVIF.
-
Trung
me too. I suppose coz it use hardware to decode which is not widely available ?
-
singpolyma
Almost no xmpp client supports svg for anything. It's something I'm slowly adding to mine
-
lovetox
singpolyma: it's mostly not up to clients
-
singpolyma
Jpeg and PNG are well supported of course, and webp support is pretty good
-
lovetox
You have a gui framework or lib that loads pictures
-
lovetox
And necessary deps just need to be installed
-
lovetox
In gajim we use gtk pixbuf and pillow
-
lovetox
So we probably support everything under the moon. But user needs to install those libs
-
singpolyma
Yes, gajim supports webp fine these days because of that. So long as OS is new enough to have pixbuf webp
-
☭民兵
Yes. I hope clients support SVG too. By the way, I guess clients should not draw it as the file specified inside then resize, draw it in a small size directly would be safe?
-
Zash
Link Mauve has had a SVG avatar for a long time, I expect it to work fine
-
singpolyma
SVG it would be nice to have consideration in some of the XEPs as well since base64 encoding xml to put back into XML is sad
-
singpolyma
But I'd take just better support
-
☭民兵
Once I created a bad SVG which made the display size too large, it made my web browser consumes too much RAM.✎ -
☭民兵
Once I created a bad SVG which made the display size too large, it made my web browser consume too much RAM. ✏
-
☭民兵
> Link Mauve has had a SVG avatar for a long time, I expect it to work fine It works well, though Conversations does not support it for now.
-
Link Mauve
singpolyma, on the desktop, AVIF and SVG are very well supported.
-
☭民兵
> me too. I suppose coz it use hardware to decode which is not widely available ? AVIF can be decoded by CPU too, as a fall back.✎ -
☭民兵
> me too. I suppose coz it use hardware to decode which is not widely available ? AVIF can be decoded by CPU too, as a fallback. ✏
-
singpolyma
Link Mauve: good to know. More reason for me to finish integration in my app
-
Link Mauve
And there is an excellent CPU implementation called libdav1d.
-
Link Mauve
Zash, I still have an SVG avatar. :)
-
Link Mauve
singpolyma, base64 XML isn’t much of an issue, the operation of de-base64-ing text is extremely cheap in comparison to the parsing and rendering process.
-
singpolyma
Big waste of space though, which is at a premium in a stanza
-
lissine
I believe AVIF and SVG are well supported on the web as well
-
singpolyma
lissine: yes of course, everything gets good support on web first
-
Link Mauve
☭民兵, in resvg, which I use in some unrelated project lately, there are two different steps in the API: first it parses it into some internal representation which is still vector-based, and then there is another function to actually transform that into a bitmap.
-
Link Mauve
The benefits are that you can re-render it at a different size much cheaper than if you had to redo the whole process.
-
Link Mauve
singpolyma, the lack of compression is a much bigger waste of space, and we don’t use that at all since there is no MIME type for svgz.
-
Link Mauve
SVG, especially as generated by Inkscape or similar tools, is very redundant at times.
-
Link Mauve
Inkscape will include the same CSS snippet on every single element, even when it doesn’t differ from the defaults.
-
singpolyma
I doubt compress then b64 will be smaller than uncompressed
-
Link Mauve
I recommend using a tool like svgcleaner before upload if you care about the stanza size.
-
singpolyma
Oh sure, optimized SVG is a thing
-
Link Mauve
singpolyma, yesterday I had a look at a SVG icon for some software, it was 17 KiB at first, 7 KiB compressed, 5 KiB uncompressed but after svgcleaner, and 3 KiB compressed after svgcleaner.
-
Link Mauve
That was a random Inkscape output.
-
Link Mauve
A dataset of one, but common in my experience.
-
Link Mauve
After base64 that would be 23 KiB.
-
Link Mauve
Note that this is still around the median of the avatar sizes of my contacts.
-
Trung
to me svg is the source from author and png is for publish and consuming
-
Link Mauve
Trung, it depends what you want to do.
-
Trung
it much less headache to open the svg, hit export to png for wherever you want to publish. Allow me to adjust the design appropiately too
-
Link Mauve
Which adjustments do you make?
-
Trung
depends
-
Trung
https://trung.fun/logo.png is my main logo. The space around it is intentional. But if you look at my avatar, it is punched in quite a bit. And my favicon is broken on purpose.
-
Trung
depends on brand and design and etc
-
singpolyma
> to me svg is the source from author and png is for publish and consuming No. PNG is always bigger and lower quality than SVG ↺
-
singpolyma
For vector stuff of course I mean
-
Trung
yes correct. the source file is always bigger
-
singpolyma
I think that's the opposite of what I said
-
Trung
sorry more flexible i meant
-
Trung
don't let that stop you doing svg for avatar tho. i can see you adding effects into it which can open new creative doors. why not
-
Link Mauve
Although for animations, no renderer besides web ones support that. :(
-
Link Mauve
Trung, with SVG you can reference external elements with the <use/> element and draw them wherever you want at whichever size you want, with as many or as few borders as you want.
-
Link Mauve
This isn’t a feature of any bitmap format in wide usage (that I know of).
-
Link Mauve
AVIF comes close with invisible frames, but that’s in a single file, you can’t reference frames in a different file.
-
Link Mauve
singpolyma, it really depends on the size at which you render, very small PNGs are almost always smaller than the source SVG.
-
Link Mauve
But with the trend of having very high DPI in screens, some icon which used to be small like 32×32 can now be 128×128 on some screens and now you have to ship all of the intermediate sizes.
-
singpolyma
> Although for animations, no renderer besides web ones support that. :( Yes, this is true of the one I'm currently using also ☹️ ↺
-
Link Mauve
Even without going that way, people like to zoom in and now you have to re-render at a different scale even if they didn’t change screens.✎ -
Link Mauve
Even without going that way, people like to zoom in and now you have to re-render at a different scale even if they didn’t change screens, or it will look blurry and bad. ✏
-
Trung
Not all designer like to work with code... 🙂
-
singpolyma
Not sure how that's related :)
-
Trung
> Trung, with SVG you can reference external elements with the <use/> element and draw them wherever you want at whichever size you want, or as few borders as you want. `<use/>` is code rite? are there a gui buttons to do that in inkscape and the like?
-
Trung
conditional branching is second nature when you're familiar with programing but if you grap 10 graphic designers and ask them to do such thing, i bet you all 12 of them will surrender
-
Link Mauve
Trung, yes there is, right click > Clone.
-
Link Mauve
In object mode.
-
singpolyma
>> Trung, with SVG you can reference external elements with the <use/> element and draw them wherever you want at whichever size you want, or as few borders as you want. > `<use/>` is code rite? are there a gui buttons to do that in inkscape and the like? Yes of course. No one* writes thier SVG by hand as code ↺
-
Link Mauve
Conditional rendering in SVG is <switch/>.
-
Trung
yeah … i don't think people use the features very often. they would rather render png. it's less headache
-
Link Mauve
Trung, on my system, only 55 out of 1220 SVG icons use a <use/> element.
-
Link Mauve
It is a common feature, even if you didn’t know it existed until now. :)
-
Link Mauve
Some of these SVGs are created by Illustrator too, so I assume this software also knows how to use <use/>.
-
Trung
thank you Link Mauve. I'd still render to png tho. I like to reserve my brain for other things when doing graphics
-
Trung
😁
-
Link Mauve
What I am trying to say is, know your tools, it’s always useful to not feel limited by them.
-
Trung
limit is mother of all creation
-
singpolyma
Yeah, PNG can't help but look ugly since it can't be safely rendered at any size but the one it was created with. So it's really a desperate last resort kind of format IMO. Unless it's a painting or photo and was raster to begin with of course
-
Menel
I think webm ist better then png for nearly everything
-
singpolyma
Menel: you mean webp? For the purposes of this raster vs vector discussion it's identical :) but yes it's got better compression than PNG usually
-
Menel
Yes 🙂 too muc stuff out therr✎ -
Menel
Yes 🙂 too muc stuff out there ✏
-
Link Mauve
Not even, WebP has the annoying property (inherited from VP8) of only supporting 4:2:0 chroma subsampling, which means any schema or image using sharp colour changes will look extremely ugly.
-
Link Mauve
If you go for lossless WebP you won’t get this issue, but it is a completely different format actually.
-
Link Mauve
And it doesn’t have much benefit over PNG.
-
Link Mauve
It also can’t use hardware video decoders VP8 WebP uses.
-
Link Mauve
If you want an image format based on a video codec, AVIF is better in every way.
-
MSavoritias (fae,ve)
heh didnt know it was that bad
-
Link Mauve
It does support 4:4:4 subsampling at almost no additional cost, 10-bit for nicer gradients, and the usual animations, transparency, etc.
-
Link Mauve
And it has hardware decoding support.
-
Link Mauve
For much smaller file size for an equivalent quality to VP8.✎ -
Link Mauve
For a much smaller file size for an equivalent quality to VP8. ✏
-
Link Mauve
At a much smaller file size for an equivalent quality to VP8. ✏
-
singpolyma
> If you go for lossless WebP you won’t get this issue, but it is a completely different format actually. Yes, when I talk about webp in the same conversation as PNG I mean lossless of course ↺
-
Link Mauve
Most people mean VP8 and not lossless when they talk about Webp.✎ -
Link Mauve
Most people mean VP8 and not lossless when they talk about WebP. ✏
-
singpolyma
That's not useful to compare to png though since PNG is lossless. Lossy webp one compares to jpeg
-
Link Mauve
Not even, JPEG is usually nicer at still images.
-
singpolyma
Sure, you can prefer jpeg, but it's a fair comparison at least
-
Trung
Whats wrong with gif?
-
singpolyma
Trung: palletized colour
-
singpolyma
No alpha
-
Zash
pallettes are cool tho
-
Trung
subsample? ...how many screens are there that display 444 10bit?
-
Trung
and color calibrated every week by professional
-
Link Mauve
singpolyma, GIF actually supports more than 256 colours, but still 1-bit alpha.
-
Link Mauve
Trung, 4:4:4, almost every screen which isn’t a shitty TV.
-
Link Mauve
10-bit, high end screens, but that is still useful for gradients, and especially in dark areas where the difference between two adjacent colours is huge.
-
Link Mauve
Programs which display 10-bit images on 8-bit or 6-bit panels will usually dither them, a technique which costs a lot in bitrate but is free when you do rendering.
-
Link Mauve
Trung, also GIF compresses much less than PNG for an equivalent image.
-
Link Mauve
(With some exceptions.)
-
Trung
Does your phone display 444? How big is the screen ?
-
Link Mauve
Trung, phone displays use RGB LEDs, so each pixel can independently set each component in the colour.
-
Link Mauve
They don’t depend on the colour of the pixels on the sides.
-
Link Mauve
4:2:0 is where groups of 2×2 pixels share the same chroma value, but still have different luma intensities.
-
Trung
the only time i ever need 444 10bit is when i still need to push color of the image and do vfx. After the render it almost always down to 422 coz no one needs all that fancy thing with gigantic size
-
Trung
420
-
Link Mauve
Trung, as I said, with modern codecs like AV1 the difference between 4:2:0 and 4:4:4 is around 5% of the bitrate.
-
Link Mauve
And even with JPEG it’s pretty common to use 4:4:4, when you don’t want to destroy the quality too much.
-
Link Mauve
4:2:0 is more common in videos, not so much for still images.
-
Trung
Yeah gif is not still tho
-
Trung
> 10-bit, high end screens, but that is still useful for gradients, and especially in dark areas where the difference between two adjacent colours is huge. You can't see the gradient details from consumer screen i think. The colors they display are off aniway.
-
Link Mauve
Trung, GIF doesn’t do 4:2:0.
-
Link Mauve
Also no, gradient banding is totally visible on consumer screens, and don’t depend on calibration.
-
Trung
Yeah i agree
-
Link Mauve
Here is one exagerated example:
-
Link Mauve
https://upload.wikimedia.org/wikipedia/commons/9/9a/Colour_banding_example01.png
-
Trung
I wasnt agaisnt u lol i need bed
-
Trung
Ừ đúng rồi
-
Trung
Oh no wrong window sorry
-
Zash
Ok now do 24-bit gradient, dithered and animated
-
Zash
or, heck, 8bit animated dithering will beat your 24 bits every day!
-
Link Mauve
Zash, this one is a wrong example because it is a single component, so 24-bit actually means 8-bit for the previous discussion.
-
Link Mauve
24-bit is actually 3×8-bit, one for each of red, green and blue, so for a black to red gradient we only use one component, the red one.
-
Zash
Link Mauve, remember/seen the thing where someone squeees insane quality out of a friggin 1-bit monochrome screen?
-
Link Mauve
I can’t find a good example right now, but take any video shot in a very dark environment, if it’s encoded in 8-bit (per component, so 24-bit) it will have very visible banding artifacts, if it’s encoded in 8-bit but with dithering the file size will be huge, if it’s encoded in 10-bit (per component, so 30-bit) it will look great and have a small bitrate.
-
Link Mauve
Zash, sure, I even have a video player on the GameBoy. :p
-
Link Mauve
The quality isn’t great, especially the audio quality at 3-bit. :D
-
Trung
> I can’t find a good example right now, but take any video shot in a very dark environment, if it’s encoded in 8-bit (per component, so 24-bit) it will have very visible banding artifacts, if it’s encoded in 8-bit but with dithering the file size will be huge, if it’s encoded in 10-bit (per component, so 30-bit) it will look great and have a small bitrate. Yeaah thats rite. Bitrate and siza aint evryth
-
Menel
Web centric comparison :https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Image_types
-
Martin
> Link Mauve has had a SVG avatar for a long time, I expect it to work fine Link Mauve ever had an avatar? 🫣
-
Martin
I only see him as 'L'.
-
Zash
I bet that L is a svg tho!
-
Martin
Hmm.
-
Link Mauve
Martin, Android still doesn’t support SVG…
-
Zash
What year is this???
-
MSavoritias (fae,ve)
🤦
-
singpolyma
It will probably only take me a couple hours to fix this once I get back to my house, so I should just do it
-
☭民兵
> Not even, WebP has the annoying property (inherited from VP8) of only supporting 4:2:0 chroma subsampling, which means any schema or image using sharp colour changes will look extremely ugly. Comrade Link Mauve, you are an expert of picture formats! That is my experience too. WebP encoder provides a mode called “near-lossless”, which deals little damage to sharp colour. How do you think about that? It looks like it is causing damage before using lossless encode.
-
☭民兵
I think WebP is far better than PNG in all ways except the resolution is limited in 16383×16383.✎ -
☭民兵
I think WebP is far better than PNG in all ways except the resolution is limited in 16383×16383. But that resolution is far enough for me. ✏
-
☭民兵
> I bet that L is a svg tho! Yes. Now it is.
-
☭民兵
I do not know any advantage of GIF when comparing it with WebP.
-
☭民兵
If somebody really cares about sharp colour, they must use lossless but not lossy, I think. If they still want to use lossy for the pictures they care about colour, they could use the “near-lossless” mode and set the parameter as they like.
-
☭民兵
>WebP encoder provides a mode called “near-lossless”, which deals little damage to sharp colour. It could produce a better quality in both visual and file size than the lossy mode of WebP.✎ -
☭民兵
>WebP encoder provides a mode called “near-lossless”, which deals little damage to sharp colour. It could produce a better quality in both visual and file size than the lossy mode of WebP when being used for simple screenshot. ✏
-
☭民兵
That would produce an amazing effect if you use the near-lossless mode to an picture with all of extremely random colour pixels, obviously better than JPEG.
-
moparisthebest
> I do not know any advantage of GIF when comparing it with WebP. Gif is probably still more widely supported ↺
-
☭民兵
Well... I hope it will be abandoned in the future, if not, then this world is too conservative.
-
moparisthebest
Web browser older than 2 weeks? Sorry can't run this website. Image format 15 years old? Sorry still not supported
-
☭民兵
It's not like that... Unless the ternary computer is newly invented in the future...
-
Zash
Yeah it's actulaly 6 weeks that's the treshold.
-
Zash
and SVG is 22 years old?