7 ms·
Real-time GIF images
- ai233 11y agoIntriguingly, I've been thinking about exactly the same thing recently.
- popmystack 11y agoI am confused? How is this being upvoted? This kind of project has been a staple in the programming community from gaming to forums for two decades now.
- vanderZwan 11y ago"Why are people upvoting something they didn't know about that I did know about?"
- GPGPU 11y agoB.b.but! He knew about it before it was cool!
- popmystack 11y agoThis site isn't for "today I learned"'s. There is a reasonable limit to the context of conversation and submissions that happen here. And instead of being snarky, you could actually explain what is so novel about dynamic image generation on a server.
- andreyf 11y agoIt has? Can you give an example? This is generating a custom GIF file on the server. It's most likely been done by someone somewhere before, but not something I've been both gaming and forum-ing for a little while.
- pluma 11y agoThis is roughly how early webcams worked. So, it's indeed not novel.
- scoot 11y agoThe Roxen [1] web-server had a much more advanced example of this for a site they produced for a watch manufacturer. The watch on the home-page displayed the current time with moving hands that were behind reflective glass. It was a server rendered gif. (c) 1996 or '97. [1] http://roxen.com http://roxen.com - now an Enterprise / Newsroom CMS.
- minimaxir 11y agoGaming forums did generated JPEGs based on time/location (so they could troll you by telling you your IP, as was typical of the teenage demographic) I have not seen a generated GIF before.
- deleted 11y ago[deleted]
- kmfrk 11y agoPHP. On my Hacker News? :)
- skimmas 11y agoI believe gmail caches all the images so that leaves out a huge amount of the world maiboxes.
- moron4hire 11y agoAnd regardless, I cannot support a project that I know will primarily be used to annoy the shit out of me in my own inbox.
- jeffjose 11y agoDont dismiss something just because the current usecase doesnt suit you.
- moron4hire 11y agoActually, I implemented this very thing in C# on top of weather radar imagery back in 2006 (to be able to overlay real-time weather on a 3rd party mapping widget), so I've given the entire concept full consideration already.
- jeffjose 11y agoYou're right. Google changed the way they did images a while back to prevent email image marketers who used to track when the user opened an email using a 1pixel transparent image downloads.
- hoorayimhelping 11y agoThey changed about two years ago to run all images sent to a gmail address through their servers (and presumably store them). It specifically didn't effect marketing though. I was working in email marketing at the time and there was some temporary gnashing of teeth but this was not much more than a blip. https://blog.filippo.io/how-the-new-gmail-image-proxy-works-and-what-this-means-for-you/ https://blog.filippo.io/how-the-new-gmail-image-proxy-works-...
- andreyf 11y ago
- DaGardner 11y agofrom the source code: "Updated at 2007. 02. 13. '00.05.AM'"
- JosephRedfern 11y agoUrmm, going by the filename ("GIFEncoder.class.php"), that's just the GIF Encoder. This post isn't about the ability to generate GIFs using PHP (as that class does), but about varying the content of the GIF on a per-request basis (in "real-time"). Looking at the git commit history, this was created ~2 days ago.
- donatj 11y agoMotion JPEG is arguably better suited to the task as the browser knows not to cache the previous frames by rule. It's actually designed for this exact purpose. I made a little example project a few years back. The format is dead simple, keep the connection open, flush multiple JPEGS separated by a header. It's used pretty often by cheap security cameras and is supported by most browsers. It just seems to be not widely known about. https://github.com/donatj/mjpeg-php https://github.com/donatj/mjpeg-php
- nacs 11y agoI've found MJPEG to be more bandwidth intensive, especially as the resolution increases however, since its flushing the full frame every time (whereas with GIF you could send just the differences between frames).
- donatj 11y agoWould depend on what you're sending. If you take make good advantage of gif interframe transparency and are just sending small updates the result could be very small. That still leaves the problem unless I'm mistaken of the browser hanging on to the old gif frames.
- dag11 11y agoI had a lot of fun making a little real-time visitor counter using Motion JPEG a few years ago! I was quite proud of that :) The demo is still live: http://drewgottlieb.net/2012/07/29/real-time-user-count.html http://drewgottlieb.net/2012/07/29/real-time-user-count.html
- ishener 11y agowhy not go to the next level and do Real-time video generation: https://pv.idomoo.com/ https://pv.idomoo.com/
- erikvdven 11y agoWell, the purpose of the code is to use it in mail clients. And because mail clients don't allow you to use javaScript and such, using an image is the most obvious alternative.
- oakwhiz 11y agoThe only issue with this kind of hack is that it uses a lot of bandwidth continuously, as long as the image exists. I wouldn't exactly consider GIF to be a good compression format for live streaming. This might not be an issue for users on broadband internet connections, but on low bandwidth, metered cell phone networks, and congested Wifi networks, this could cause issues (such as slowdowns or unintentionally using up your metered bandwidth allocation) that wouldn't be nearly as bad if a piece of Javascript was used to live-update a page instead. I wonder if it would be possible to make a live WebM version of this instead.
- akovaski 11y agoIf I read the source code correctly, this is not actually streaming something continuously; instead, it is making a 30-frame gif that has a start-time that is dependent on when you loaded the gif.
- witty_username 11y agoAdditionally, GIF has only 256 colors.
- geographomics 11y agoOnly 256 colours per frame, but they don't have to be the same ones, and can be combined to use a wider palette - for example: http://notes.tweakblogs.net/blog/8712/high-color-gif-images.html http://notes.tweakblogs.net/blog/8712/high-color-gif-images....
- jacquesm 11y agoFunny how we go full-circle. This is roughly the way I did live video in '95.
- david927 11y agoWhen I read the title, the first thing I did was laugh and think about telling you to 'check this new thing out'.
- pluma 11y agoFirst thing I thought of when I read the title were 1990s era webcams.
- amelius 11y agoI don't think it is really funny. Hacks like this is how progress is delayed. Because why innovate when you can rely on "hacks that provably work in the real world"?
- Kristine1975 11y agoThis hack is an innovation in its own right. And it should work with most browsers, contrary to completely new technology.
- anewhnaccount 11y agoThis is better: https://github.com/videlalvaro/gifsockets https://github.com/videlalvaro/gifsockets - it's event based so doesn't tie up lots of memory while running and doesn't stop after 30 frames.
- andreyf 11y agoOh, this is actually neat: > what about progress bars for stuff that your server is doing in the background This seems like a really good micro-service.
- barrystaes 11y agoYep, i was expecting OP's code to be the PHP implementation of that, but a quick look at index.php shows its not. Streaming gif frames, now thats what i call a live gif.
- deleted 11y ago[deleted]
- erikvdven 11y agoYes, the idea is brilliant! But the purpose of my source code is to use "real-time" gif images in mail clients. Unfortunately, videlalvaro's solution is only possible for mail clients which support loading images from its original source. Google loads the images from their proxy, which downloads the images first. It DOES re-download each image at the moment you re-open the e-mail message, but it won't make it possible to manipulate the images real-time. I've tested it. It does work in clients like outlook, cause outlook shows the images from its original source, but gmail doesn't. So sending a gif image with a certain amount of frames is better, in my opinion.
- 0xcde4c3db 11y agoThis reminds me of an IOCCC entry (further details elided; read the hint file if you want it "spoiled") [1] [1] IOCCC 2013 winner, most timely rendered: http://www.ioccc.org/2013/mills/ http://www.ioccc.org/2013/mills/
- niftyimages 11y agoGreat bit of source code. We've taken a similar approach to create free timers for email marketers. https://niftyimages.com/TryIt/Timers https://niftyimages.com/TryIt/Timers
- swanson 11y agoFunny coincidence -- I just received an email with a countdown like that today and was very curious. In my case, the email was using: https://www.realtime.email/ https://www.realtime.email/
- erikvdven 11y agoNow you can do it yourself haha ;) I still have to cleanup the code a bit. Thinking of creating a class which allows you to create such image by just writing a multidimensional array, so less code to write. But I couldn't wait to share this already so... But updates are coming soon.
- scottydelta 11y agoWell a good way to troll. You send an image to someone in the email and then change the image once the person forwards this email to others.
- fudged71 11y agonot just trolling but could also be used for social engineering...
- Herrera 11y agoYou are right. You receive one image containing a inspirational message for your family and decide to send to your family members. Then it changes to a image asking for money to be sent to an account because you are in need. I could see this working.
- tcdent 11y agoI'm mildly baffled by the coding style of the main encoder class[0]; where do these conventions come from? (All-caps three character properties, namespaced(?) arguments, spaces e v e r y w h e r e, curly bracket array access.) Also, I didn't know `class` and `array` were case-insensitive. [0] https://github.com/ErikvdVen/php-gif/blob/master/GIFEncoder.class.php https://github.com/ErikvdVen/php-gif/blob/master/GIFEncoder....
- viraptor 11y agoComments say it's based on this: https://github.com/demouth/DmImage/blob/master/example/sample_node/animate/GifMerge.class.php https://github.com/demouth/DmImage/blob/master/example/sampl... Some of what you mentioned is already present there. Some other things are new. But they're both terrifying... Extra details: the rewrite into gifencoder happened in 2007, so gifmerge must be older than that (maybe 4.x times). The original license forbids modifying gifmerge without author's approval - since this file doesn't mention it at all, I doubt dmimage is legal.
- otakucode 11y ago> But they're both terrifying... Welcome to PHP! Truly the language which most directly represents the soul of the web - a stateless static documentation presentation system which we shoehorn application functionality into regardless of the pain!
- mr_clump 11y agoThe classic coding book 'Code Complete' recommends adding spaces after and before brackets. The idea being the increased white space improves code readability. I used to agree, but more recently have decided it ultimately ends up making things more difficult to read by increasing the amount of scanning your eyes need to do.
- biot 11y agoNetscape did a similar thing to this in 1994 with their Fishcam, converting frames from a video capture and served up as new frames of a GIF image. It was eventually shut down in 2007 and the original developer[0] setup a dedicated site for it: http://www.fishcam.com/ http://www.fishcam.com/ Nice to see the forgotten technology repurposed. [0] http://www.montulli.org/lou http://www.montulli.org/lou