View Full Version : BLOB image to Thumbnail on Server
02-26-2010, 11:09 AM
I have images stored as a blob in my database.
I would like to retrieve these images as a thumbnail and displayed using php.
I would prefer the images to be saved on the server rather than the database.
I guess there would need to be a way of checking if the thumbnail already exists to that new thumbnails dont get generated needlessly.
I have gd-library installed but dont know where to go from here :(
02-26-2010, 01:51 PM
So now, all images are in the database, and you don't yet have a place to store them in a directory?
We of course have no access or info on your database or scripts.
No way to even begin to show an actual example.
You'll have to make the change-over in steps ...
1) Create a place (directory) to store images.
2) Add a new field (variable) to the MySQL table for the "filename" of the image.
3) Alter the upload part of the script so it stores the image in the directory and
writes the filename in the table.
4) Try uploading some to test it out.
Now, you'll end-up with a mix ... some will still be in MySQL and others will be in a directory. You didn't say how many there were ... maybe it would be easiest to
re-upload all of them using the new upload changes? Later on, remove the images
from the database and the conversion will be complete.
If you have too many images to upload, you'll have to write a script to remove them
from blob and put them into the directory instead. You have the part about the
filenames to deal with though.
Just converting from blob to storing in a directory is a major part.
The part about displaying as thumbnails (on the fly GD) is another thing to worry about later, separate from the issue of blob.
02-27-2010, 10:47 AM
Thanks for your advice.
Currently I have a news management for where news articles can be uploaded.
The image for the news item gets added as a blob when the form is submitted.
I now require at the php end to retrieve these images and show a thumbnail alongside the news item headline. The user clicks the headline and they are taken through the the news in detail with a larger image.
I think it would probably be best to alter the table to have 2 image fields:
image (blob - a resized image of the original photo the user uploaded)
image_thumb (blob - a super-resized image of the original photo the user uploaded)
I'm using Oracle tables so I'm probably best on the Oracle forums by the sound of it? :)
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.