Re: Should I put pictures into a database?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wednesday 21 November 2007 03:14:43 Ronald Wiplinger wrote:
> I have an application, where I use pictures. The size of the picture is
> about 90kB and to speed up the preview, I made a thumbnail of each
> picture which is about 2.5 to 5kB.
> I use now a directory structure of   ../$a/$b/$c/<pictures>

I rather to store images on the file-system, since database is another
level over the file-system. However, I still need to store a pointer for
every image into the database. This leads to storing the file names
twice: one time in file-system, and one time in db.
Isn't this redundancy?

Sometimes we can avoid this, especially if we have an image per
record (e.g., Users' Avatars).

Suppose you allow each user to upload a GIF/PNG/JPEG image;
the below code assigns the correct image for every user:

    foreach ($users as &$user) {
        $user['avatar'] = reset(glob('../img/avatars/' . $user['id'] .
'.*'));
    }

If you can grant the images are .GIF, then you can reduce the
overhead of searching for images:

    foreach ($users as &$user) {
        $user['avatar'] = '../img/avatars/' . $user['id'] . '.gif';
    }

Regards,
Behzad

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux