-2

I've been wondering on how to resize image and store it into database.

So far, I could store the image into database. Now, I want to create the the thumbnail of relevant image and store it in differently with my actual image.

Let's say, from an image.jpg, I want to store the actual image into file_data (LONGBLOB) and its thumbnail into thumbnail_data (BLOB).

But, I don't know how to resize the image. I've tried several tutorials but nothing works for me.

Please help? Sorry for troubling you guys.

=======================(newly added part)

I was thinking to store the image into database because I need the relation within the data stored in each row.

I have this in my database table

image_id | identifier | filename | mime_type | file_size | file_data | thumbnail_data

Identifier is used to classify the images when they get uploaded.

Let's say I have this:

1 | newyork | ny1 | ... 2 | newyork | ny3 | ... 3 | newyork | ny2 | ... 1 | taiwan | tw1 | ...

the images will be displayed as:

New York:

ny1.jpg ny3.jpg ny2.jpg

Taiwan:

tw.jpg

Coderama
  • 87
  • 2
  • 9

1 Answers1

3

Emm... you do not want to store binary data in a database. What you (and everyone else) should do is store the files on the filesystem and put pointers to the files in the database.

image_id | identifier | file_location         | mime_type | file_size | thumbnail_location
1        | foo        | /images/hd1/first.png | image/png | 10240     | /images/thumbnails/hd1/first.png
hd1
  • 33,938
  • 5
  • 80
  • 91