473,320 Members | 1,872 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

General Design and Programming Question

Hello PHP group,

I looks like this is a good forum to ask my question. I am using both
PHP and MySQL.
I would like/am designing a photo database for the web - not heavy duty
- not complex, like menalto Gallery, etc. My idea is to use PHP and
MySQL. I would like to store the images in the MySQL database, and
display them using PHP. I would like to have a table with thumbnail
images, that when "clicked" will link to a veiw page that will display
a larger version of the thumbnail.

My guess is that the thumb nail will be around 200px wide and 250px
high (or maybe less , in the 100px area). I figure I will have the
larger image at around 800x600 pixels, at 72dpi.

I have some basic code that puts the image(s) in my database, and can
call the image using a view image.php page.

I do not plan to fully automate this procedure. Perhaps i will
automate the thumbnail creation (netpbm, etc).

Any suggestons the newsgroup might have on this basic design, etc will
be quite helpful.
thanks,

eholz1

Dec 12 '06 #1
9 1341
eholz1,

The thumbnailing you mention can easily be done using calls to gdlib
pages. I do pretty much exactly what your talking about right now on a
couple sites. When a user uploads an image i thumbnail it and save the
thumbnail and main image to the db setting the parent id of the
thumbnail to the main images id.

Google something like "php thumbnail gdlib" and youll prolly come up
with a dozen tutorials or examples.
eholz1 wrote:
Hello PHP group,

I looks like this is a good forum to ask my question. I am using both
PHP and MySQL.
I would like/am designing a photo database for the web - not heavy duty
- not complex, like menalto Gallery, etc. My idea is to use PHP and
MySQL. I would like to store the images in the MySQL database, and
display them using PHP. I would like to have a table with thumbnail
images, that when "clicked" will link to a veiw page that will display
a larger version of the thumbnail.

My guess is that the thumb nail will be around 200px wide and 250px
high (or maybe less , in the 100px area). I figure I will have the
larger image at around 800x600 pixels, at 72dpi.

I have some basic code that puts the image(s) in my database, and can
call the image using a view image.php page.

I do not plan to fully automate this procedure. Perhaps i will
automate the thumbnail creation (netpbm, etc).

Any suggestons the newsgroup might have on this basic design, etc will
be quite helpful.
thanks,

eholz1
Dec 12 '06 #2
eholz1,

The thumbnailing you mention can easily be done using calls to gdlib
functions. I do pretty much exactly what your talking about right now
on a couple sites. When a user uploads an image i thumbnail it and save
the thumbnail and main image to the db setting the parent id of the
thumbnail to the main images id.

Google something like "php thumbnail gdlib" and youll prolly come up
with a dozen tutorials or examples.
eholz1 wrote:
Hello PHP group,

I looks like this is a good forum to ask my question. I am using both
PHP and MySQL.
I would like/am designing a photo database for the web - not heavy duty
- not complex, like menalto Gallery, etc. My idea is to use PHP and
MySQL. I would like to store the images in the MySQL database, and
display them using PHP. I would like to have a table with thumbnail
images, that when "clicked" will link to a veiw page that will display
a larger version of the thumbnail.

My guess is that the thumb nail will be around 200px wide and 250px
high (or maybe less , in the 100px area). I figure I will have the
larger image at around 800x600 pixels, at 72dpi.

I have some basic code that puts the image(s) in my database, and can
call the image using a view image.php page.

I do not plan to fully automate this procedure. Perhaps i will
automate the thumbnail creation (netpbm, etc).

Any suggestons the newsgroup might have on this basic design, etc will
be quite helpful.
thanks,

eholz1
Dec 12 '06 #3
Hello there,
I will check it out, thanks for the info.

eholz1
Areric wrote:
eholz1,

The thumbnailing you mention can easily be done using calls to gdlib
functions. I do pretty much exactly what your talking about right now
on a couple sites. When a user uploads an image i thumbnail it and save
the thumbnail and main image to the db setting the parent id of the
thumbnail to the main images id.

Google something like "php thumbnail gdlib" and youll prolly come up
with a dozen tutorials or examples.
eholz1 wrote:
Hello PHP group,

I looks like this is a good forum to ask my question. I am using both
PHP and MySQL.
I would like/am designing a photo database for the web - not heavy duty
- not complex, like menalto Gallery, etc. My idea is to use PHP and
MySQL. I would like to store the images in the MySQL database, and
display them using PHP. I would like to have a table with thumbnail
images, that when "clicked" will link to a veiw page that will display
a larger version of the thumbnail.

My guess is that the thumb nail will be around 200px wide and 250px
high (or maybe less , in the 100px area). I figure I will have the
larger image at around 800x600 pixels, at 72dpi.

I have some basic code that puts the image(s) in my database, and can
call the image using a view image.php page.

I do not plan to fully automate this procedure. Perhaps i will
automate the thumbnail creation (netpbm, etc).

Any suggestons the newsgroup might have on this basic design, etc will
be quite helpful.
thanks,

eholz1
Dec 12 '06 #4

eholz1 schrieb:
Hello PHP group,

I looks like this is a good forum to ask my question. I am using both
PHP and MySQL.
I would like/am designing a photo database for the web - not heavy duty
- not complex, like menalto Gallery, etc. My idea is to use PHP and
MySQL. I would like to store the images in the MySQL database, and
display them using PHP.
I wonder, if storing images in a MySQL DB is a wise choice.

Why not generate a unique/random name for each image and store a
reference to these names in an SQL table?

Are there are good reasons, to transfer the whole images through your
MySQL connections and make table rows large?

Dec 13 '06 #5
seaside wrote:
eholz1 schrieb:

>>Hello PHP group,

I looks like this is a good forum to ask my question. I am using both
PHP and MySQL.
I would like/am designing a photo database for the web - not heavy duty
- not complex, like menalto Gallery, etc. My idea is to use PHP and
MySQL. I would like to store the images in the MySQL database, and
display them using PHP.


I wonder, if storing images in a MySQL DB is a wise choice.

Why not generate a unique/random name for each image and store a
reference to these names in an SQL table?

Are there are good reasons, to transfer the whole images through your
MySQL connections and make table rows large?
Actually, quite a few reasons. Makes backups easier, ensures your
database remains consistent, you don't need to keep track of thousands
of images in one directory, no worries about name collisions, remote
access...

I can keep going.

It won't take any longer to transfer the image through the MySQL
connection if you're on the same server, and probably less time than
establishing a new connection to download the file if both were on a
different system. And table rows will be larger - but you'll still have
to take up that space in the file system, anyway.

I find storing images in the database can be very effective.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Dec 13 '06 #6
..oO(Jerry Stuckle)
>Actually, quite a few reasons. Makes backups easier, ensures your
database remains consistent, you don't need to keep track of thousands
of images in one directory, no worries about name collisions, remote
access...
None of them is a real problem.
>It won't take any longer to transfer the image through the MySQL
connection if you're on the same server
It will _definitely_ take longer, see below.
>And table rows will be larger - but you'll still have
to take up that space in the file system, anyway.
A typical RDBMS is not very effective in handling large binary data,
simply because it's not made for that purpose.
>I find storing images in the database can be very effective.
I don't. In some rather rare cases there might be reasons to do it, but
usually it will be a performance hit, especially when you want to build
an image gallery with a lot of images.

For every(!) single non-static image you have to call a PHP script,
which already slows things down:

<img src="/getImage.php?file=foo.jpg" alt="">

It gets even worse if every script call also has to open a connection to
the database and fetch the image from there. A hundred images on a page
means a hundred script calls and a hundred database connections. Compare
that to static images that are delivered instantly by the webserver.

Currently I'm in a situation where I will have to deliver large image
galleries entirely by scripts, including the images, for security
reasons (I use my own auth system, not HTTP authentication). I really
expect a dramatically impact on downloading time when the script is
finished. I don't like to do it, but in this case there's no other way.

Micha
Dec 13 '06 #7
Michael Fesser wrote:
.oO(Jerry Stuckle)

>>Actually, quite a few reasons. Makes backups easier, ensures your
database remains consistent, you don't need to keep track of thousands
of images in one directory, no worries about name collisions, remote
access...


None of them is a real problem.
Sure they are. What happens if you accidentally delete an image from a
directory? What if you have the images on another server and want to
restrict access? NFS may not be available. How about keeping thousands
of images in a single directory? Even Linux slows down when the number
of images gets big enough. And how about keeping track of names so you
don't get duplicates?

They are all real problems.
>
>>It won't take any longer to transfer the image through the MySQL
connection if you're on the same server


It will _definitely_ take longer, see below.
It doesn't have to.
>
>>And table rows will be larger - but you'll still have
to take up that space in the file system, anyway.


A typical RDBMS is not very effective in handling large binary data,
simply because it's not made for that purpose.
Have you actually checked? I think you'll find MySQL can be quite
effective in handling them. And RDBMS's are made to handle data - even
large blobs, which is all the image is to the database.
>
>>I find storing images in the database can be very effective.


I don't. In some rather rare cases there might be reasons to do it, but
usually it will be a performance hit, especially when you want to build
an image gallery with a lot of images.
That's our choice. But I find performance to be quite good, and
improves with larger numbers of images.
For every(!) single non-static image you have to call a PHP script,
which already slows things down:
So? If you want to protect your images, you'll have to call your PHP
script anyway. No big deal.
<img src="/getImage.php?file=foo.jpg" alt="">
So?
It gets even worse if every script call also has to open a connection to
the database and fetch the image from there. A hundred images on a page
means a hundred script calls and a hundred database connections. Compare
that to static images that are delivered instantly by the webserver.
So? Every script also has to open a file and read it in. A hundred
images on a page means a hundred script calls and a hundred file system
accesses. Worse if the data is on another server (and not available via
NFS).
Currently I'm in a situation where I will have to deliver large image
galleries entirely by scripts, including the images, for security
reasons (I use my own auth system, not HTTP authentication). I really
expect a dramatically impact on downloading time when the script is
finished. I don't like to do it, but in this case there's no other way.

Micha
That could be. But I don't think you'll find a database to make things
any worse.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Dec 13 '06 #8
..oO(Jerry Stuckle)
>Sure they are. What happens if you accidentally delete an image from a
directory?
User error. What if you accidentally issue a DELETE FROM query without a
WHERE clause?
>What if you have the images on another server and want to
restrict access?
Can be done without a database.
>How about keeping thousands
of images in a single directory? Even Linux slows down when the number
of images gets big enough.
Depends on the filesystem. But anyway, it would make sense to use some
subdirectories (one for each gallery) instead of just throwing them all
together.
And how about keeping track of names so you
don't get duplicates?
The same way as you would do in a database: auto-generated IDs (if
necessary).
>They are all real problems.
But easy to solve.
>It will _definitely_ take longer, see below.

It doesn't have to.
Calling a script and querying a database will always be slower than just
returning a static file.
>For every(!) single non-static image you have to call a PHP script,
which already slows things down:

So? If you want to protect your images, you'll have to call your PHP
script anyway. No big deal.
Question is if the images in a gallery have to be protected (the OP
didn't mention that) or not.

Micha
Dec 14 '06 #9
Michael Fesser wrote:
.oO(Jerry Stuckle)

>>Sure they are. What happens if you accidentally delete an image from a
directory?


User error. What if you accidentally issue a DELETE FROM query without a
WHERE clause?
And it can happen. If you issue a DELETE FROM without a WHERE clause,
the data may or may not be deleted. If you have properly set up the
foreign keys with ON DELETE RESTRICT, data will not be deleted. ON
DELETE CASCADE, the data will be deleted. However, in either case, the
database is consistent. Not so if you just delete a file which is still
being referenced in the database.
>
>>What if you have the images on another server and want to
restrict access?


Can be done without a database.
OK, pray tell, how? Assuming you're on a shared host without NFS
capabilities, for instance.
>
>>How about keeping thousands
of images in a single directory? Even Linux slows down when the number
of images gets big enough.


Depends on the filesystem. But anyway, it would make sense to use some
subdirectories (one for each gallery) instead of just throwing them all
together.
And that requires additional programing to keep track of each of the
subdirectories, where the files are, etc. Or what if you only have one
gallery?

In a database they're all in one place.
>
>And how about keeping track of names so you
don't get duplicates?


The same way as you would do in a database: auto-generated IDs (if
necessary).
Again, extra programming. But here you also have to ensure two
concurrent accesses don't generate the same filename. Databases do that
for you.
>
>>They are all real problems.


But easy to solve.
With additional programming and complications.
>
>>>It will _definitely_ take longer, see below.

It doesn't have to.


Calling a script and querying a database will always be slower than just
returning a static file.
Not necessarily. Do you have the statistics to prove this? I have.
For instance, if the data is cached in the DB, accessing it through
MySQL can be faster than through the file system. And if the images
reside on a remote system, access will virtually always be faster
through MySQL than through ftp, http, etc. access.
>
>>>For every(!) single non-static image you have to call a PHP script,
which already slows things down:

So? If you want to protect your images, you'll have to call your PHP
script anyway. No big deal.


Question is if the images in a gallery have to be protected (the OP
didn't mention that) or not.

Micha
Nope. But you brought it up, in your code. So I responded to it.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Dec 14 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: kneejerkreaction | last post by:
I did not know where else to post this since there is no forum for general OOP questions. I am just getting into OOP after a lifetime of procedural programming. I'm developing a Help Desk Ticketing...
8
by: Jolly Student | last post by:
Dear Colleagues: I am a systems guy who has been working with hardware, networking and basic scripting for ten years or so. I have been given the opportunity to attend ..Net classes of all...
17
by: tshad | last post by:
Many (if not most) have said that code-behind is best if working in teams - which does seem logical. How do you deal with the flow of the work? I have someone who is good at designing, but...
6
by: Ivan Weiss | last post by:
I am designing a class to represent an item in a database (containing model's of products). I need to display a listing of all of these items in a listview to be displayed to the user (so they can...
105
by: Christoph Zwerschke | last post by:
Sometimes I find myself stumbling over Python issues which have to do with what I perceive as a lack of orthogonality. For instance, I just wanted to use the index() method on a tuple which does...
6
by: JoeC | last post by:
I have a question about designing objects and programming. What is the best way to design objects? Create objects debug them and later if you need some new features just use inhereitance. Often...
19
by: neelsmail | last post by:
Hi, I have been working on C++ for some time now, and I think I have a flair for design (which just might be only my imagination over- stretched.. :) ). So, I tried to find a design...
3
by: Mike TI | last post by:
Aug 2, 2007 12:00pm Hi all I have to design and program an application which will be used in three countries. It would be a fairly large application with lot of data entry. The database...
40
by: RvGrah | last post by:
I've been writing in C# for about 4 years now, coming from VB.net and VB6 before that, in which I know I'm not alone. I found learning C#, at least to the extent that I use it in developing...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.