Top
Best
New

Posted by vitaut 19 hours ago

Regressive JPEGs(maurycyz.com)
642 points | 65 comments
Retr0id 13 hours ago|
I did something very similar with progressive (adam7 interlaced) PNG: https://www.da.vidbuchanan.co.uk/adamation/image.png

> so playback is entirely dependent on network delay

Ultimately true, but I set up my server to send each "frame" separately, with a fixed delay between each. Each frame is small so unless your network is unusually slow, the timing is set by my server.

omoikane 6 hours ago||
If you have control over the HTTP server, a different technique is to set "refresh" in the response header[1], which makes the client fetch new animation frames periodically. This is the technique used in a 2013 IOCCC entry to show a continuously updated clock that's rendered as PNG[2].

[1] https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/...

[2] https://www.ioccc.org/2013/mills/index.html

The "Refresh" header is encoded backwards on this line:

https://github.com/ioccc-src/winner/blob/619f554bbdb19e5003a...

jbochi 13 hours ago|||
And I did something similar to steam live video via an infinite gif: https://github.com/jbochi/gifstreaming#live-video-streaming-...
Dwedit 10 hours ago|||
Interesting that people are making hacks of PNG to do animations, yet there's also APNG sitting over there saying "Hey I exist!"
donatj 10 hours ago|||
You don't even need a hack, there's built-in support for this.

https://en.wikipedia.org/wiki/Motion_JPEG

I've been here screaming "Motion JPEG EXISTS and is well supported in browsers" the entire time those gif hacks were popular. I've built a bunch of cool stuff with it.

https://github.com/donatj/mjpeg-php/blob/master/mjpeg.php

https://github.com/donatj/imgboard/blob/master/main.go

The PHP example here is an illustration of how easy it is to pull off, and the Go example is part of a JavaScript-free multiuser drawing board.

qingcharles 7 hours ago||||
Sure, but most sites strip the animation out of APNGs while still allowing GIFs, which is frustrating.
Retr0id 8 hours ago|||
We even have proper video codecs like h264!
moron4hire 9 hours ago||
I did this once, 20 years ago, with an animated GIF to add a live streaming air quality layer to a map application at work. The image itself was rendered using Java2D. I had a version I was working on that used JOGL to make gradient blobs instead of point clouds, but I couldn't get the server admin to install the OpenGL driver to get it to work.
robbak 15 hours ago||
That is 1. Cursed, and 2. Definitely in the right place here.
qurren 5 hours ago||
Meanwhile the big techs:

"Hmm how can we use this for fingerprinting"

alterom 14 hours ago||
This is the stuff that I come here for.
bartread 11 hours ago|||
Weekend HN is definitely where the more interesting and offbeat content lives, and I often find myself enjoying it significantly more as a result.

During the week, well, it would be unfair to call it LinkedInified, but it can often feel like a somewhat higher tier of that sort of strata. Plenty of good stuff in there still, but much more “serious business”.

wegwerf17377382 13 hours ago|||
Me too, thanks for reminding me of that
tda 14 hours ago||
I wonder if and how you can use this for steganography, hiding data in plain sight. I bet most automated image analysis programs would only consider the final image. I sure some highschooler can use this to bypass their schools contentfilter
aetherspawn 13 hours ago||
Yep this is an AI subversion technique for sure. Put the message to the humans in the first frame, and the message to the AI in the final frame.

This is how we defeat skynet: by sending each other pictures of cats.

yonatan8070 11 hours ago||
You could probably implement a server that is purposefully slow enough so that the human frame shows up for however long you want. Just need to send the keepalive bytes one-by one.
mike_hock 13 hours ago||
I can't see any way this would beat regular steganography.
pavlov 13 hours ago||
> “Besides unconventional rickrolls and other trolling, this has no practical applications: there's no way to add timing information, so playback is entirely dependent on network delay.”

A progress bar for something that’s loading in parallel over the same network, to give the user an idea of how much the delay is?

NewsaHackO 10 hours ago|
If i remember correctly, some other places of the internet (4chan) completely this sort of behavior because people use it to hide images of ...unsavory topics
Gander5739 7 hours ago||
I think you dropped a word.
SonOfLilit 5 hours ago||
It's an onomatopoeia
Gander5739 4 hours ago||
You mean an onomatope (to be pendantic)? In any case, it's not clear to me exactly what you mean.
tosti 51 minutes ago|||
Someone accidentally the whole thing.
SonOfLilit 1 hour ago|||
Apparently "onomatope" is a much less popular name for the same thing (e.g. Wikipedia uses my version).

I mean that the "remove a word" 'symbol' is a 'word' that represents the verb he was trying to invoke, by sounding like it.

Birds chirp, bees buzz, moderators, toilets flush.

Gander5739 55 minutes ago||
Apologies if I'm being totally thick, but you're saying the lack of a word is acting as an onomatope (or an onomatopoeia if you prefer)?
cousin_it 16 hours ago||
Nice! I think you can approximate timing somewhat, by making your web server create the "jpeg" on the fly and send it to the client in timed chunks. The source could even be a webcam, so the "jpeg" would go on forever.
londons_explore 15 hours ago||
There are already webcams which do this- but they use a mime trick for 'multipart/x-mixed-replace'.

That's basically the server telling the client 'That data I just sent you, well now replace it with this new thing'.

No JavaScript needed, and can work with plain http and jpeg

SahAssar 14 hours ago|||
A lot of IP cameras already do this via https://en.wikipedia.org/wiki/Motion_JPEG
iwontberude 13 hours ago||
You can do this with the gif too, I have once created a toy cgi that combined a gif sending one frame at a time with an image map allowing you to Remote Desktop with no JavaScript and click around. JPEG may have been a better choice, maybe I’ll revisit this.
est 14 hours ago||
> so playback is entirely dependent on network delay

You can use Service Worker to emulate a slow connection :)

snailmailman 5 hours ago||
Weird that it’s inconsistent

Works fine for me in desktop Firefox. But on mobile iOS the “whole video within a jpeg” is 3 frames, all of which are nearly entirely solid color brown->orange->red with a vague cat silhouette. The color changes each frame, so you can tell it’s “working” but it’s certainly not what I’d call a video.

I was surprised when I pulled it up on my desktop and it did actually play like a video. Wonder if it’s causing some weird iOS image decoding glitch/edge case.

Yokohiii 14 hours ago||
Adjacent advice: I've recently played with opengl and jpeg turbo and I wanted to display images fast. I don't remember exact numbers, but enabling progressive for a jpeg was a significant slowdown for decoding. So if anyone like me is stuck with the old school advice that progressive is an nice to have, it's likely not. I personally don't remember any visual progressive image buildup in like decades, so it's not doing anything valuable at all.
msm_ 11 hours ago||
>I personally don't remember any visual progressive image buildup in like decades, so it's not doing anything valuable at all.

Maybe you just don't notice? It can be pretty invisible sometimes. I sometimes notice that image soon after page load an image is slightly blurry, and then another pass "sharpens" it. Yeah it's not like in the "old times" when the first progressive level was almost unreadable, but there's still value in sending a lower resolution version of image in 30% of the total file-size, basically for free

jrochkind1 8 hours ago||
I haven't been able to see it even setting Chrome developer tools to crazy slow network speeds. Maybe chrome developer tools simulation isn't enough to see it?

The observations you are reporting are from images you created yourself and you know are in fact progressive jpegs? (not "regressive", although that's funny). There are of course other techniques to start with a lower resolution image that do "work" (in the sense of actually displaying a lower resolution image first at least).

chronogram 13 hours ago|||
I use cjpegli as encoder and it compresses best with its default progressive and full 4:4:4 approach, so it's not only a nice to have feature.
Yokohiii 12 hours ago||
I deliberately was talking about decode speed. The question is if you serve even via moderately fast infra, does it display faster? In my case on a (indeed fast) local system absolutely not. Mere size can be a decode problem of course. But it's extremely hard to tell that a single digit percent size difference is an advantage for serving.

But if better compression for storage or you can verify progressive serves faster then it is of course a benefit.

I guess the point I am making is that most people think: I heard it's somehow better so lets use it.

Dylan16807 4 hours ago||
Is you have a normal CPU then does decode speed matter?

But a lot of people do have slow connections sometimes.

Self-Perfection 13 hours ago|||
JPEG photos stored as progressive usually take ~5% less space so there is value.

And it is possible to losslessly transcode JPEG to progressive.

Lossless transcoding to JPEG XL gives even more space savings though.

cubefox 13 hours ago|||
Progressive decoding isn't expected to speed up decoding, it's expected to speed up displaying large image files, especially for downloads via slow mobile connections.

Example: https://youtube.com/watch?v=UphN1_7nP8U

Yokohiii 12 hours ago||
I've started using computers in the 90s, I've seen this every day back then.

Still the question is, does it help? Trying to access an average web app will probably take minutes before the browser may even see an image. If you do everything possible to render reasonably fast on very slow speeds, then progressive is nice. On a fast connection I don't think the average user will notice the difference.

phyzome 8 hours ago||
Where it helps is in finding out if it's even the image you wanted. You get a sense of it from the fast first pass, and then can hit back if it's not the thing you thought it was.
PatuDev 5 hours ago||
[flagged]
schobi 16 hours ago||
I tried to think about difficult ways to compute the high frequency coefficients to work from the "wrong" coefficients of the first image...

But this is clever - just smash them together. Low frequency of one image concatenated with high frequency from another. This works surprisingly well!

smath 7 hours ago|
Is it possible to acquire lower frequency components with a camera too?

This also reminded me of MRI where low frequency is acquired first in a space called k-space

More comments...