Can JPEG's be animated?
I like to follow challenges in random ideas. Today I wake up and check my email there I found one image, which loaded differently as it seemed to me and I wondered — if it was a JPG, how it possible to animate it?
JPEG format supports the progressive loading, that does not support animation itself, but I thought it could create the illusion of animation.
How? Let's find out!
The image refines in multiple passes, but it's controlled by the encoder, not dynamically like an animation.
We can create an illusion of movement by revealing parts of an image in a way that suggests motion, like a falling star leaving a trail by placing a few static frames one-by-one, but little bit shifted. Progressive loading algorithms will load more data leaving old frames in place and adding new ones and move forward. Maybe we can shift image visually by draw more and more details and move them but it will still stay as a static image.
Simple idea, impossible to realize.
Where is the point you say? There is a no point here — except the "Madness and courage".
/* With a little possibility, you can create a company's logo which will be animated as it loads. */
I'm afraid you even will not recognize this without disabling cache for this particular image. The image should be so large that you will need to observe how slowly it loads. Nowadays and in future I thing it will be less possible.
Custom Progressive Encoding
There is one chance to archive this — some tools (like jpegrescan or mozjpeg) allow fine-tuning scan layers. You could structure an image so that the first scans reveal a basic shape (e.g., the star), and later scans introduce more details along a trajectory.
Don't be folly, use right tools
There are many healthy alternatives for this: animated WebP/APNG/GIF, SVG or CSS Masking, Layered Images + JavaScript, MP4 and many other video and scripting animation formats. Even use multiple progressive JPEGs stack to preload a first layer and then use JavaScript to swap in an animated sequence of images progressively, but this would be inefficient compared to native animation formats.
You can choose simple straight-forward way and choose a right tool for this or you can go your own path by overengineering and hacking.
Good luck!