I did something like this a while ago ... and while it might not be the best
solution - here's my situation and my solution:

I had a number of photos (just shy of 1000) ...

all were from various theatre shows ... taken at a different time of the
process (rehearsal ... performance etc).

So - I set up the following table in MySQL:

Photo ID - an auto increment integer
Show ID - an integer
Time ID - an integer
Imagetype - a string (JPG or Gif etc)

When the file was then uploaded - the user selects a show and time to store
it under. The file is then transferred to a directory numbered thus :


When I then want to find a photo - it does a query over the database,
retrieves the information and can access the photo appropriately.

The downside of this - is that in order to know which photo is which - you
have to access the database first.

Dunno if that helps - but I thought I'd share my experience.


-----Original Message-----
From: Scott Houseman [mailto:[EMAIL PROTECTED]]
Sent: 21 August 2002 14:39
To: Justin French; PHP General
Subject: RE: [PHP] Image library

Hi all.

This confirms what I suspected.

The hash algrithm:

I have a directory structure: dirs 0 - f, and within each of these, the same
dir structure 0 - f.
When an image gets uploaded into the library, do an md5sum of the file, take
the first 2 chars of that hash
and there's your path. e.g

I'm not sure what the mathematical randomness of this is, but I'm sure it's
pretty random, and the chances
of collision should be virtually null, the only time you should overwrite a
file is if you upload the exact same file(?)
Is there a better way of doing this?



> -----Original Message-----
> From: Justin French [mailto:[EMAIL PROTECTED]]
> Sent: 21 August 2002 03:25
> Subject: Re: [PHP] Image library
> on 21/08/02 9:45 PM, Scott Houseman ([EMAIL PROTECTED]) wrote:
> > Which way would be the most efficient/fastest to access images
> from an image
> > library.
> > A) Store image files in a hash directory structure AND storing
> each file's
> > information in a mysql table
> > OR
> > B) Storing image information in mysql table AND storing the
> image in a BLOB
> > field in that table.
> >From all accounts I've read on this list, a database is not
> usually faster
> than a filesystem.  And for large amounts of files, like 1000's,
> a hash will
> speed it up more.
> > The way I see it, considerations to be taken into acount:
> > - Is it quicker/better to retrieve image from table & then stream out to
> > browser OR simply direct the browser to the file?
> > i.e <IMG SRC="/imagelib/image.php?iImageID=10"> OR <IMG
> > SRC="/imagelib/5/f/10">
> > - Will a database OR filesystem be more scalable i.e. which wil perform
> > better when there are 10000 images in the libary?
> Filesystem should be quicker.  You need to think about how you hash the
> files up for the most even spread of files in each directory I guess.
> Justin

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

This message has been checked for all known viruses by the 
MessageLabs Virus Control Centre.

This message has been checked for all known viruses by the MessageLabs Virus Control 


Notice:  This email is confidential and may contain copyright material of Ocado 
Limited (the "Company"). Opinions and views expressed in this message may not 
necessarily reflect the opinions and views of the Company.
If you are not the intended recipient, please notify us immediately and delete all 
copies of this message. Please note that it is your responsibility to scan this 
message for viruses.

Company reg. no. 3875000.  Swallowdale Lane, Hemel Hempstead HP2 7PY


PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to