jdev - 2023-07-30


  1. ☭民兵

    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?

  2. Menel

    Picture too large is not an issue with the max stanza size currently

  3. Link Mauve

    ☭民兵, for avatars explicitly, XEP-0084 requires it to be present in PNG, with additional nodes in different formats if this is wanted.

  4. Link Mauve

    I would say SVG rendering is more CPU bound than AVIF or other bitmap formats, especially when using filters.

  5. Link Mauve

    But it has the very useful property of being a vector format, so it can be rendered at any size.

  6. Link Mauve

    Also AVIF usually uses the video decoder hardware for decoding, thus completely freeing the CPU while decoding happens.

  7. ☭民兵

    Thank you for telling me that.

  8. Menel

    I've never seen avif in the wild yet, do clients support that?

  9. ☭民兵

    I do not care about this situation. I guess very less people know and use AVIF.

  10. Trung

    me too. I suppose coz it use hardware to decode which is not widely available ?

  11. singpolyma

    Almost no xmpp client supports svg for anything. It's something I'm slowly adding to mine

  12. lovetox

    singpolyma: it's mostly not up to clients

  13. singpolyma

    Jpeg and PNG are well supported of course, and webp support is pretty good

  14. lovetox

    You have a gui framework or lib that loads pictures

  15. lovetox

    And necessary deps just need to be installed

  16. lovetox

    In gajim we use gtk pixbuf and pillow

  17. lovetox

    So we probably support everything under the moon. But user needs to install those libs

  18. singpolyma

    Yes, gajim supports webp fine these days because of that. So long as OS is new enough to have pixbuf webp

  19. ☭民兵

    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?

  20. Zash

    Link Mauve has had a SVG avatar for a long time, I expect it to work fine

  21. 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

  22. singpolyma

    But I'd take just better support

  23. ☭民兵

    Once I created a bad SVG which made the display size too large, it made my web browser consumes too much RAM.

  24. ☭民兵

    Once I created a bad SVG which made the display size too large, it made my web browser consume too much RAM.

  25. ☭民兵

    > 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.

  26. Link Mauve

    singpolyma, on the desktop, AVIF and SVG are very well supported.

  27. ☭民兵

    > 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.

  28. ☭民兵

    > 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.

  29. singpolyma

    Link Mauve: good to know. More reason for me to finish integration in my app

  30. Link Mauve

    And there is an excellent CPU implementation called libdav1d.

  31. Link Mauve

    Zash, I still have an SVG avatar. :)

  32. 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.

  33. singpolyma

    Big waste of space though, which is at a premium in a stanza

  34. lissine

    I believe AVIF and SVG are well supported on the web as well

  35. singpolyma

    lissine: yes of course, everything gets good support on web first

  36. 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.

  37. 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.

  38. 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.

  39. Link Mauve

    SVG, especially as generated by Inkscape or similar tools, is very redundant at times.

  40. Link Mauve

    Inkscape will include the same CSS snippet on every single element, even when it doesn’t differ from the defaults.

  41. singpolyma

    I doubt compress then b64 will be smaller than uncompressed

  42. Link Mauve

    I recommend using a tool like svgcleaner before upload if you care about the stanza size.

  43. singpolyma

    Oh sure, optimized SVG is a thing

  44. 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.

  45. Link Mauve

    That was a random Inkscape output.

  46. Link Mauve

    A dataset of one, but common in my experience.

  47. Link Mauve

    After base64 that would be 23 KiB.

  48. Link Mauve

    Note that this is still around the median of the avatar sizes of my contacts.

  49. Trung

    to me svg is the source from author and png is for publish and consuming

  50. Link Mauve

    Trung, it depends what you want to do.

  51. 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

  52. Link Mauve

    Which adjustments do you make?

  53. Trung

    depends

  54. 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.

  55. Trung

    depends on brand and design and etc

  56. 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

  57. singpolyma

    For vector stuff of course I mean

  58. Trung

    yes correct. the source file is always bigger

  59. singpolyma

    I think that's the opposite of what I said

  60. Trung

    sorry more flexible i meant

  61. 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

  62. Link Mauve

    Although for animations, no renderer besides web ones support that. :(

  63. 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.

  64. Link Mauve

    This isn’t a feature of any bitmap format in wide usage (that I know of).

  65. Link Mauve

    AVIF comes close with invisible frames, but that’s in a single file, you can’t reference frames in a different file.

  66. Link Mauve

    singpolyma, it really depends on the size at which you render, very small PNGs are almost always smaller than the source SVG.

  67. 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.

  68. singpolyma

    > Although for animations, no renderer besides web ones support that. :( Yes, this is true of the one I'm currently using also ☹️

  69. 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.

  70. 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.

  71. Trung

    Not all designer like to work with code... 🙂

  72. singpolyma

    Not sure how that's related :)

  73. 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?

  74. 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

  75. Link Mauve

    Trung, yes there is, right click > Clone.

  76. Link Mauve

    In object mode.

  77. 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

  78. Link Mauve

    Conditional rendering in SVG is <switch/>.

  79. Trung

    yeah … i don't think people use the features very often. they would rather render png. it's less headache

  80. Link Mauve

    Trung, on my system, only 55 out of 1220 SVG icons use a <use/> element.

  81. Link Mauve

    It is a common feature, even if you didn’t know it existed until now. :)

  82. Link Mauve

    Some of these SVGs are created by Illustrator too, so I assume this software also knows how to use <use/>.

  83. Trung

    thank you Link Mauve. I'd still render to png tho. I like to reserve my brain for other things when doing graphics

  84. Trung

    😁

  85. Link Mauve

    What I am trying to say is, know your tools, it’s always useful to not feel limited by them.

  86. Trung

    limit is mother of all creation

  87. 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

  88. Menel

    I think webm ist better then png for nearly everything

  89. 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

  90. Menel

    Yes 🙂 too muc stuff out therr

  91. Menel

    Yes 🙂 too muc stuff out there

  92. 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.

  93. Link Mauve

    If you go for lossless WebP you won’t get this issue, but it is a completely different format actually.

  94. Link Mauve

    And it doesn’t have much benefit over PNG.

  95. Link Mauve

    It also can’t use hardware video decoders VP8 WebP uses.

  96. Link Mauve

    If you want an image format based on a video codec, AVIF is better in every way.

  97. MSavoritias (fae,ve)

    heh didnt know it was that bad

  98. 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.

  99. Link Mauve

    And it has hardware decoding support.

  100. Link Mauve

    For much smaller file size for an equivalent quality to VP8.

  101. Link Mauve

    For a much smaller file size for an equivalent quality to VP8.

  102. Link Mauve

    At a much smaller file size for an equivalent quality to VP8.

  103. 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

  104. Link Mauve

    Most people mean VP8 and not lossless when they talk about Webp.

  105. Link Mauve

    Most people mean VP8 and not lossless when they talk about WebP.

  106. singpolyma

    That's not useful to compare to png though since PNG is lossless. Lossy webp one compares to jpeg

  107. Link Mauve

    Not even, JPEG is usually nicer at still images.

  108. singpolyma

    Sure, you can prefer jpeg, but it's a fair comparison at least

  109. Trung

    Whats wrong with gif?

  110. singpolyma

    Trung: palletized colour

  111. singpolyma

    No alpha

  112. Zash

    pallettes are cool tho

  113. Trung

    subsample? ...how many screens are there that display 444 10bit?

  114. Trung

    and color calibrated every week by professional

  115. Link Mauve

    singpolyma, GIF actually supports more than 256 colours, but still 1-bit alpha.

  116. Link Mauve

    Trung, 4:4:4, almost every screen which isn’t a shitty TV.

  117. 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.

  118. 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.

  119. Link Mauve

    Trung, also GIF compresses much less than PNG for an equivalent image.

  120. Link Mauve

    (With some exceptions.)

  121. Trung

    Does your phone display 444? How big is the screen ?

  122. Link Mauve

    Trung, phone displays use RGB LEDs, so each pixel can independently set each component in the colour.

  123. Link Mauve

    They don’t depend on the colour of the pixels on the sides.

  124. Link Mauve

    4:2:0 is where groups of 2×2 pixels share the same chroma value, but still have different luma intensities.

  125. 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

  126. Trung

    420

  127. 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.

  128. 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.

  129. Link Mauve

    4:2:0 is more common in videos, not so much for still images.

  130. Trung

    Yeah gif is not still tho

  131. 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.

  132. Link Mauve

    Trung, GIF doesn’t do 4:2:0.

  133. Link Mauve

    Also no, gradient banding is totally visible on consumer screens, and don’t depend on calibration.

  134. Trung

    Yeah i agree

  135. Link Mauve

    Here is one exagerated example:

  136. Link Mauve

    https://upload.wikimedia.org/wikipedia/commons/9/9a/Colour_banding_example01.png

  137. Trung

    I wasnt agaisnt u lol i need bed

  138. Trung

    Ừ đúng rồi

  139. Trung

    Oh no wrong window sorry

  140. Zash

    Ok now do 24-bit gradient, dithered and animated

  141. Zash

    or, heck, 8bit animated dithering will beat your 24 bits every day!

  142. 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.

  143. 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.

  144. Zash

    Link Mauve, remember/seen the thing where someone squeees insane quality out of a friggin 1-bit monochrome screen?

  145. 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.

  146. Link Mauve

    Zash, sure, I even have a video player on the GameBoy. :p

  147. Link Mauve

    The quality isn’t great, especially the audio quality at 3-bit. :D

  148. 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

  149. Menel

    Web centric comparison :https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Image_types

  150. Martin

    > Link Mauve has had a SVG avatar for a long time, I expect it to work fine Link Mauve ever had an avatar? 🫣

  151. Martin

    I only see him as 'L'.

  152. Zash

    I bet that L is a svg tho!

  153. Martin

    Hmm.

  154. Link Mauve

    Martin, Android still doesn’t support SVG…

  155. Zash

    What year is this???

  156. MSavoritias (fae,ve)

    🤦

  157. 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

  158. ☭民兵

    > 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.

  159. ☭民兵

    I think WebP is far better than PNG in all ways except the resolution is limited in 16383×16383.

  160. ☭民兵

    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.

  161. ☭民兵

    > I bet that L is a svg tho! Yes. Now it is.

  162. ☭民兵

    I do not know any advantage of GIF when comparing it with WebP.

  163. ☭民兵

    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.

  164. ☭民兵

    >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.

  165. ☭民兵

    >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.

  166. ☭民兵

    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.

  167. moparisthebest

    > I do not know any advantage of GIF when comparing it with WebP. Gif is probably still more widely supported

  168. ☭民兵

    Well... I hope it will be abandoned in the future, if not, then this world is too conservative.

  169. moparisthebest

    Web browser older than 2 weeks? Sorry can't run this website. Image format 15 years old? Sorry still not supported

  170. ☭民兵

    It's not like that... Unless the ternary computer is newly invented in the future...

  171. Zash

    Yeah it's actulaly 6 weeks that's the treshold.

  172. Zash

    and SVG is 22 years old?