#!/usr/bin/perl
use CGI; #Hate this
use DBI;
print "Content-type: image/jpeg\n\n";
binmode STDOUT; #win32;
my $dbh = DBI->connect("relevant stuff here");
my $image_date;
my $sth = $dbh->prepare("SELECT data FROM images WHERE id=?");
$sth->execute( param('img') );
$sth->bind_column( \$image_data ); #erm. I think
$sth->fetch; $sth->finish; $dbh->disconnect;
print $image_data;
#done
| [reply] [d/l] |
| [reply] [d/l] [select] |
Slightly different take on the problem - if you want to publish an animation of the last 24 hours weather then convert your JPGs into a an animated GIF (using imagemagick or similar). This is the way that I have seen it done on public meteorology sites.
Checkout the convert method. It looks like you will be able to convert a number of jpegs to gifs and animate them. | [reply] |
Some background info might be useful. Why are the images being stored in a database? Do you need to be able to access images farther back than the 50-100 images needed for animation? Are those 50-100 images always going to be the most recent ones? What's the expected number of views? I'd personally store the images in folders by day using some naming system involving timestamps, thus making it unnecessary to use a database to access the images. | [reply] |
Whether to store images in a database or not has been much talked about on the MySQL lists. The general consensus seems to be that you should store the image files in a filesystem since that's what a filesystem is designed for and store the html links to the images in a database since they're data for your program and that's what a database is for.
Jack
| [reply] |
| [reply] |
| [reply] |