I have added a png image to a table in the database as a BLOB. Adding the image into the database is trivial. However, being able to display the BLOB back to the .png image format is bewildering me.
Examples are hard to come by... How to display the BLOB back to the image?
This simple example only displays the raw binary data:
my (@images) = query("SELECT name FROM test_file WHERE id='$id'");
foreach my $img(@images)
{
print $img; # Displays the blob gobble de gook
}
I have heard people using BINMODE but again, I can't get that to do anything useful:
open(IMAGE, ">/tmp/file.png");
binmode IMAGE;
print IMAGE $img;
close(IMAGE);
Any examples are much appreciated.
Regards,
ns