Version 7 (modified by 12 years ago) ( diff ) | ,
---|
Using PERL and Javascript to control animated images
I was hoping javascript would offer more control over GIFs, but it doesn't look like it. It can, however, control a slideshow of images. So, I wrote a javascript control page and PERL script to search an HTML file for GIF links, make directories & convert each GIF into sets of PNG images, then replace the original GIF link with one that points to a page containing the javascript slideshow controls.
The PERLscript is located on shell, in /home/yirak/bin/publish.pl
.
The webpage author can control whether or not to convert a given GIF and whether or not to resize it to 640x?.
The tag should be as follows:
<a HREF="..." ... [unpack={0|1}] [resize={0|1}]> ... </a>
where both unpack
and resize
are optional; the defaults are unpack=1 and resize=1.
!!! NOTE: The HREF tag must be all on one line. !!!
The script should be fairly easy to use:
Instructions
- Write your
index.html
page like you normally would, including GIFs. - Denote GIFs you don't want processed with
unpack
- Denote GIFs you don't want resized (typically this means downsized) to 640x? with
resize
- Run
publish.pl
from the same directory asindex.html
. It will create a backup of your page,index.html.backup
. - Voila!
If you want to run it on a webpage other than index.html
, pass the filename as an argument to publish.pl
.
The javascript gets information about the image set from the URL: initial frame, final frame, directory, interval between frames (optional).
If you need to rerun the script
Assuming your file is index.html
, the perlscript will copy this to index.html.backup
and will modify index.html
. Thus, if you want to add another GIF & rerun the script, you must
:~> mv index.html.backup index.html :~> publish.pl