Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Sep 2007
    Thanked 0 Times in 0 Posts

    BLOB image to Thumbnail on Server


    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

  • #2
    Master Coder
    Join Date
    Jun 2003
    Cottage Grove, Minnesota
    Thanked 1,096 Times in 1,087 Posts
    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.
    Last edited by mlseim; 02-26-2010 at 02:54 PM.

  • #3
    Regular Coder
    Join Date
    Sep 2007
    Thanked 0 Times in 0 Posts
    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?


    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts