Image gallery question: Better to save the thumbnails in the database?

Discussion in 'Programming/Scripts' started by padmx82, Jan 3, 2007.

  1. padmx82

    padmx82 New Member

    Hi, I´m currently developing an Image Gallery in PHP and MySQL.

    I´m saving the images into the database (using BLOB), what I would like to know is:
    Which is the best way to handle the thumbnails for the images,
    is it better to save the thumbnails into the database also, or generate the thumbnails every time a visitor enter the gallery?

    Also, this Gallery will be in a external hosting service, so I thought that is better to save the images into the database (considering the amount of storage available), am I correct or should I not save the images into the database but in a folder?

    Thanks in advance
    Padmx

    Sorry for my english, I´m from Mexico
     
  2. Ben

    Ben ISPConfig Developer ISPConfig Developer

    As you describe it you have to things to make clear
    1.) Where to generally store the images
    2.) Geneate thumbs in realtime or just upon uploading a picture.

    Starting with 2.) if you do not expect that much users and thumbs per page you can generate them by realtime. But keep in mind that it takes much cpu in comparison with just generating the thumbs while the normal pics get uploaded.
    Space is cheaper than cpu power

    Regarding 1.) i had both with no problems. But take care of escaping not that you get in trouble with manual escape + magic_quotes... or just use base64 but that enlarges the content.
    Aynway i would take the way of just storing the images to the disk, don't really see, why they have to in the DB. What you should store there is e.g. mimetype, width, height etc. in case you need that information.

    hth
     
  3. padmx82

    padmx82 New Member

    Thanks for your reply, Ben.

    There will be just 5 thumbs in every page, so as you say, it will be just fine if I generate the thumbs in real time.

    As for where to save images (either disk or DB), I think I will use the DB, I don´t remember well, but I think there is a function in PHP that makes the saved strings smaller when using BLOB, so I will just google for info on that..

    Thanks again
    Padmx
     

Share This Page