Created
October 17, 2024 09:22
-
-
Save rubenarakelyan/a35994de769192b1ba3a92d138f5f0ff to your computer and use it in GitHub Desktop.
Server-push animation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warning; | |
use GD; | |
$images = "/path/to/images"; | |
$header = "Content-type: multipart/x-mixed-replace; boundary=ddc072ce-3b52-4704-9fef-abf661a13d43\n"; | |
$boundary = "\n--ddc072ce-3b52-4704-9fef-abf661a13d43\n"; | |
$giftype = "Content-type: image/gif\n\n"; | |
print $header; | |
print $boundary; | |
$i = 1; | |
while (1) { | |
sleep 1; | |
print $giftype; | |
open(GIFH, "< ${images}/frame${i}.gif"); | |
$img = newFromGif GD::Image(GIFH); | |
close(GIFH); | |
print $img->gif; | |
print $boundary; | |
if ($i == 21) { | |
$i = 1; | |
} else { | |
$i++; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment