Most active commenters
  • account42(7)
  • fc417fc802(5)
  • pornel(3)

←back to thread

A new PNG spec

(www.programmax.net)
618 points bluedel | 35 comments | | HN request time: 1.532s | source | bottom
Show context
albert_e ◴[] No.44373786[source]
So animated GIFs can be replaced by Animated PNGs with alpha blending with transparent backgrounds and lossless compression! Some nostalgia from 2000s websites can be revived and relived :)

Curious if Animated SVGs are also a thing. I remember seeing some Javascript based SVG animations (it was a animated chatbot avatar) - but not sure if there is any standard framework.

replies(10): >>44373806 #>>44373868 #>>44374146 #>>44374225 #>>44374312 #>>44374556 #>>44374786 #>>44376132 #>>44379316 #>>44385628 #
1. riffraff ◴[] No.44373868[source]
I was under the impression many gifs these days are actually served as soundless videos, as those basically compress better.

Can animated PNG beat av1 or whatever?

replies(6): >>44374218 #>>44374256 #>>44374550 #>>44374739 #>>44375571 #>>44385655 #
2. josephg ◴[] No.44374218[source]
I doubt it, given png is a lossless compression format. For video thats almost never what you want.
replies(1): >>44374605 #
3. layer8 ◴[] No.44374256[source]
APNG would be for lossless compression, and probably especially for animations without a constant frame rate. Similar to the original GIF format, with APNG you explicitly specify the duration of each individual frame, and you can also explicitly specify looping. This isn’t for video, it’s more for Flash-style animations, animated logos/icons [0], or UI screen recordings.

[0] like for example these old Windows animations: https://www.randomnoun.com/wp/2013/10/27/windows-shell32-ani...

replies(1): >>44374716 #
4. armada651 ◴[] No.44374550[source]
> Can animated PNG beat av1 or whatever?

Animated PNGs can't beat GIF nevermind video compression algorithms.

replies(2): >>44374811 #>>44374952 #
5. DidYaWipe ◴[] No.44374605[source]
For animations with lots of regions of solid color it could do very well.
replies(1): >>44384591 #
6. fc417fc802 ◴[] No.44374716[source]
All valid points, however AV1 also supports lossless compression and is almost certainly going to win the file size competition against APNG every time.

https://trac.ffmpeg.org/wiki/Encode/AV1#Losslessencoding

replies(2): >>44375025 #>>44385663 #
7. fc417fc802 ◴[] No.44374739[source]
> many gifs these days are actually served as soundless videos

That's not really true. Some websites lie to you by putting .gif in the address bar but then serving a file of a different type. File extensions are merely a convention and an address isn't a file name to begin with so the browser doesn't care about this attempt at end user deception one way or the other.

replies(1): >>44375388 #
8. jeroenhd ◴[] No.44374811[source]
Once you add more than 256 different colours in total, GIF explodes in terms of file size. It's great for small, compact images with limited colour information, but it can't compete with APNG when the image becomes more detailed than what you'd find on Geocities.
replies(1): >>44378383 #
9. Aissen ◴[] No.44374952[source]
> Animated PNGs can't beat GIF nevermind video compression algorithms.

Not entirely true, it depends on what's being displayed, see a few simple tests specifically constructed to show how much better APNG can be vs GIF and {,lossy} webp: http://littlesvr.ca/apng/gif_apng_webp.html

Of course I don't think it generalizes all that well…

replies(3): >>44375573 #>>44375646 #>>44380354 #
10. meindnoch ◴[] No.44375025{3}[source]
False, or misleading.

The AV1 spec [1] does not allow RGB color spaces, therefore AV1 cannot preserve RGB animations in a bit-identical fashion.

[1] https://aomediacodec.github.io/av1-spec/av1-spec.pdf

replies(1): >>44378181 #
11. faceplanted ◴[] No.44375388[source]
You said that's not really true and the described exactly how it's true, what did you mean?
replies(1): >>44383933 #
12. bawolff ◴[] No.44375571[source]
Its also because people like to "pause" animations, and that is not really an option with apng & gif.
replies(1): >>44377985 #
13. ◴[] No.44375573{3}[source]
14. bmacho ◴[] No.44375646{3}[source]
I tried these examples on ezgif, and indeed apng manages to be smaller than webp every single time. Weird, I was under the impression that webp was almost always smaller? Is this because GIF images are already special, or apng uses better compression than png?

edit: using the same ezgif webp and apng on a H.264 source, apng is suddenly 10x the size than webp. It seems apng is only better if the source is gif

replies(3): >>44376096 #>>44383964 #>>44385690 #
15. Aissen ◴[] No.44376096{4}[source]
I have no idea! I actually hoped someone would show a much more comprehensive and serious benchmark in response, but that has failed to materialize.
16. bigfishrunning ◴[] No.44377985[source]
why not? that's up to the program displaying the animation, not the animation itself -- i'm sure a pausable gif or apng display program is possible
replies(2): >>44378333 #>>44385668 #
17. pornel ◴[] No.44378181{4}[source]
AV1 supports YCoCg, which encodes RGB losslessly.

It is a bit-reversible rotation of the RGB cube. It makes the channels look more like luma and chroma that the codec expects.

replies(1): >>44379922 #
18. pornel ◴[] No.44378333{3}[source]
It's absolutely possible. Browsers even routinely pause playback when images aren't visible on screen.

They just don't have a proper UI and JS APIs exposed, and there's nothing stopping them from adding that.

IMO browsers are just stuck with tech debt, and maintainin a no-longer-relevant distinction between "animations" and "videos". Every supported codec should work wherever GIF/APNG work and vice versa.

It's not even a performance or complexity issue, e.g. browsers support AVIF "animations" as images, even though they're literally fully-featured AV1 videos, only wrapped in a "pretend I'm an image" metadata.

replies(2): >>44379530 #>>44379733 #
19. pornel ◴[] No.44378383{3}[source]
No, APNG explodes in size in that case.

In APNG it's either the same 256 colors for the whole animation, or you have to use 24-bit color. That makes the pixel data 3 times larger, which makes zlib's compression window effectively 3 times smaller, hurting compression.

OTOH GIF can add 256 new colors with each frame, so it can exceed 256 colors without the cost of switching all the way to 16.7 million colors.

20. joquarky ◴[] No.44379530{4}[source]
I wish browsers still paused all animations when the user hits the Esc key. It's hard to read when there are distracting animations all over most pages.
replies(1): >>44385708 #
21. nextaccountic ◴[] No.44379733{4}[source]
> They just don't have a proper UI and JS APIs exposed, and there's nothing stopping them from adding that.

Browsers should just allow animated gifs and apngs in <video>

replies(1): >>44385700 #
22. meindnoch ◴[] No.44379922{5}[source]
False.

8-bit YCoCg (even when using the reversible YCoCg-R [1] scheme) cannot represent 8-bit RGB losslessly. The chroma channels would need 9 bits of precision to losslessly recover the original 8-bit RGB values.

[1] https://www.microsoft.com/en-us/research/wp-content/uploads/...

23. armada651 ◴[] No.44380354{3}[source]
You're correct and I was considering adding a footnote that if you use indexed colors like a GIF then PNG can beat GIF due to better compression algorithms. But when most people think of APNG they think of lossless compression rather than lossy compression.
replies(1): >>44385678 #
24. fc417fc802 ◴[] No.44383933{3}[source]
I parsed the comment as something along the lines of clever hackers somehow stuffing soundless videos into gif containers which is most certainly not what is going on. I was attempting to convey that they have nothing to do with gifs. Gifs are not involved anywhere in the process.

I'm not sure why people disagree so strongly with what I wrote. Worst case scenario is that it's a slightly tangential but closely related rant about deceptive web design practices. Best case scenario is that someone who thought some sort of fancy trick involving gifs was in use learns something new.

25. fc417fc802 ◴[] No.44383964{4}[source]
I would guess that apng only wins when indexed colors can be used. That guess would match what you saw using an h264 file for the source.
26. josephg ◴[] No.44384591{3}[source]
So do most other video formats. I'm not really seeing any advantages, and I see a lot of disadvantages vs h264 and friends.
replies(1): >>44385728 #
27. account42 ◴[] No.44385655[source]
Soundless videos cannot be used in environments that expect an image like embeds in forums and similar.

It's a shame that browser vendors didn't add silent looping video support to the img tag over (imo) baseless concerns.

28. account42 ◴[] No.44385663{3}[source]
> is almost certainly going to win the file size competition against APNG every time

For video content maybe. Pixel-art gifs are not something video codecs do well at without introducing lots of artifacts.

replies(1): >>44389491 #
29. account42 ◴[] No.44385668{3}[source]
Browsers used to support pausing GIFs by pressing the escape key.
30. account42 ◴[] No.44385678{4}[source]
Indexed can be lossless when the source already uses few colors, e.g. because you want to improve the compression of an existing GIF or limit colors for stylistic choice (common in pixel art).
31. account42 ◴[] No.44385690{4}[source]
Almost like video codecs and animated images are different niches that optimize for different content.
32. account42 ◴[] No.44385700{5}[source]
More important would be to allow (silent) videos in <img>.
33. ◴[] No.44385708{5}[source]
34. account42 ◴[] No.44385728{4}[source]
Not without lots of artifacts.
35. fc417fc802 ◴[] No.44389491{4}[source]
Artifacts? We're talking about lossless compression here. There aren't any artifacts by definition.