473,595 Members | 2,619 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

What's the best option?

Hi,
I need to store lots of product images. I was thinking of storing the paths
in the database but overtime it may become cumbersome as I'll be dealing with
lots of images.

I would need to display both a thumbnail and large versions. The average
size per image is 400kb and the max display is 1702 by 2542.

Would SQL Server be a good alternative?

Thanks
May 22 '07 #1
5 1543

Storing images ~inside the db will affect performance.

Most people do it for security. (your bank has an image of your check...
for example)

...

A good compromise is:

ImagePath
IPID int , Path string
101,"C:\folder1 \"
102."C\folder2\ "

Image
ImageID int
IPID int (fk to the above table)
RelativePath string
2001, 101 , "picture\girl.j pg"
2002,101, "pictures\boy.j pg"
3001, 102, "family\mom.jpg "
3002, 102, "family\dad.jpg "

The ImagePath gives you the ability move files, and not have to update a
million rows.

Select ip.Path + i.RelativePath as FullPathName from ImagePath ip join
Image i on ip.IPID = i.IPID

so you'd get back
C:\folder1\pict ure\girl.jpg
C:\folder1\pict ures\boy.jpg
C:\folder2\fami ly\mom.jpg
C:\folder2\fami ly\dad.jpg

That's how I implement it. Esp in a big project where you have a zillion
images, the ImagePath table allows easier updating.
If you don't need security, I'd keep the files as (real) files ... and have
paths to them.

But that's me.

Its cheap (compared to pulling it out of the database) to send a url of a
file that already exists out to your client-browsers.


"Chris" <Ch***@discussi ons.microsoft.c omwrote in message
news:E8******** *************** ***********@mic rosoft.com...
Hi,
I need to store lots of product images. I was thinking of storing the
paths
in the database but overtime it may become cumbersome as I'll be dealing
with
lots of images.

I would need to display both a thumbnail and large versions. The average
size per image is 400kb and the max display is 1702 by 2542.

Would SQL Server be a good alternative?

Thanks

May 22 '07 #2
See, I am dealing with tons of images. Do I then need to store these images
on our webserver?

I didn't mention this in my original question, I was also considering after
storing them in the database, I was considering creating a webservice to
handout the images as they will be used by quite a few applications
internally as well.

Thanks

"sloan" wrote:
>
Storing images ~inside the db will affect performance.

Most people do it for security. (your bank has an image of your check...
for example)

...

A good compromise is:

ImagePath
IPID int , Path string
101,"C:\folder1 \"
102."C\folder2\ "

Image
ImageID int
IPID int (fk to the above table)
RelativePath string
2001, 101 , "picture\girl.j pg"
2002,101, "pictures\boy.j pg"
3001, 102, "family\mom.jpg "
3002, 102, "family\dad.jpg "

The ImagePath gives you the ability move files, and not have to update a
million rows.

Select ip.Path + i.RelativePath as FullPathName from ImagePath ip join
Image i on ip.IPID = i.IPID

so you'd get back
C:\folder1\pict ure\girl.jpg
C:\folder1\pict ures\boy.jpg
C:\folder2\fami ly\mom.jpg
C:\folder2\fami ly\dad.jpg

That's how I implement it. Esp in a big project where you have a zillion
images, the ImagePath table allows easier updating.
If you don't need security, I'd keep the files as (real) files ... and have
paths to them.

But that's me.

Its cheap (compared to pulling it out of the database) to send a url of a
file that already exists out to your client-browsers.


"Chris" <Ch***@discussi ons.microsoft.c omwrote in message
news:E8******** *************** ***********@mic rosoft.com...
Hi,
I need to store lots of product images. I was thinking of storing the
paths
in the database but overtime it may become cumbersome as I'll be dealing
with
lots of images.

I would need to display both a thumbnail and large versions. The average
size per image is 400kb and the max display is 1702 by 2542.

Would SQL Server be a good alternative?

Thanks


May 22 '07 #3
Yes in many cases storing images in SQL Server is a good choice.
I wrote an article on the subject here:
http://SteveOrr.net/articles/EasyUploads.aspx

Since some of your images sound quite large, you may want to do some
performance testing to ensure it will meet your requirements.

--
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net
"Chris" <Ch***@discussi ons.microsoft.c omwrote in message
news:E8******** *************** ***********@mic rosoft.com...
Hi,
I need to store lots of product images. I was thinking of storing the
paths
in the database but overtime it may become cumbersome as I'll be dealing
with
lots of images.

I would need to display both a thumbnail and large versions. The average
size per image is 400kb and the max display is 1702 by 2542.

Would SQL Server be a good alternative?

Thanks
May 23 '07 #4
Since the images are associated with products, yes, storing their paths in
the same database as the product data would be a good idea. As for the
thumbnails, you can create an HttpHandler that will open an image, create a
thumbnail, and return it to the browser. Or, you can store the thumbnails in
the same folder as the full-size images, and use a naming convention to get
them. For example:

ProductA.jpg
ProductA_thumb. jpg

This way you only have to store "ProductA.j pg" in the database, and use the
naming convention to alter the image file name for the thumbnail.

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

"Chris" <Ch***@discussi ons.microsoft.c omwrote in message
news:E8******** *************** ***********@mic rosoft.com...
Hi,
I need to store lots of product images. I was thinking of storing the
paths
in the database but overtime it may become cumbersome as I'll be dealing
with
lots of images.

I would need to display both a thumbnail and large versions. The average
size per image is 400kb and the max display is 1702 by 2542.

Would SQL Server be a good alternative?

Thanks

May 23 '07 #5

If you want to "serve them up" to a client browser, then at some point the
file has to be on the webserver.

So it depends.

If you ~can just store them on the webserver, then that's the easier option.

Or , you can "copy them on demand".

See my modified example below to start out.

ImagePath
IPID int , Path string
101,"\\fileserv er1\folderA\"
102."\\fileserv er2\folderB\"

Image
ImageID int
IPID int (fk to the above table)
RelativePath string
2001, 101 , "picture\girl.j pg"
2002,101, "pictures\boy.j pg"
3001, 102, "family\mom.jpg "
3002, 102, "family\dad.jpg "

The ImagePath gives you the ability move files, and not have to update a
million rows.

Select ip.Path + i.RelativePath as FullPathName from ImagePath ip join
Image i on ip.IPID = i.IPID

so you'd get back
\\fileserver1\f olderA\picture\ girl.jpg
\\fileserver1\f olderA\pictures \boy.jpg
\\fileserver2\f olderB\family\m om.jpg
\\fileserver2\f olderB\family\d ad.jpg

So that gives you the ORIGINAL location of the files.

If someone requests the item (product in your case) that is represented by
the dad.jpg image... you can copy it on demand.

(File Copy) from
\\fileserver2\f olderB\family\d ad.jpg
To
( web server ) C:\inetpub\wwwr oot\urlimages\

you'll have to figure out a way to have unique file names ... one way

change the filename (replace \ with _ )
fileserver2_fol derB_family_dad .jpg
and you end up wiht the file:

C:\inetpub\wwwr oot\urlimages\f ileserver2_fold erB_family_dad. jpg

That will end up being (as a web link)
http//www.mysite.com/urlimages/fileserver2_fol derB_family_dad .jpg

The reason you want a consistent file name is so you don't unnecessarily
copy images.

the logic is

rework the fileserver filename to the localfile name
see if the local filename exists
(C:\inetpub\www root\urlimages\ fileserver2_fol derB_family_dad .jpg)
if it doesn't , copy it
if it does, just keep moving
rework the url so you can give the client a url that actually works (
http//www.mysite.com/urlimages/fileserver2_fol derB_family_dad .jpg )

And then you have to write a cleanup service that runs at night or
something.
It depends what your goals are.

The solution above is good for a webfarm, because you don't have to keep X
number of copies of images (per web server). And you don't fill up the
harddrive with images.

But it takes a little work.

And based on what you're saying, I'd go with the solution above.
I've done this exact same thing. My company has millions of images we have
to serve up internally (intranet), and we have huge fileservers to hold just
the images.
The "copy on demand" solution works well.

And I STRONGLY recommend the
ImagePath
IPID int , Path string
101,"\\fileserv er1\folderA\"
102."\\fileserv er2\folderB\"

inclusion. Because eventually you'll have to move images from one file
server to another. This way you update 1 or 2 records, not thousands (or
millions) of records doing string manipulation.
Good luck.
Read the other posts about the thumbnails also. I won't repeat that
information unnecessarily.


"Chris" <Ch***@discussi ons.microsoft.c omwrote in message
news:AF******** *************** ***********@mic rosoft.com...
See, I am dealing with tons of images. Do I then need to store these
images
on our webserver?

I didn't mention this in my original question, I was also considering
after
storing them in the database, I was considering creating a webservice to
handout the images as they will be used by quite a few applications
internally as well.

Thanks

"sloan" wrote:

Storing images ~inside the db will affect performance.

Most people do it for security. (your bank has an image of your
check...
for example)

...

A good compromise is:

ImagePath
IPID int , Path string
101,"C:\folder1 \"
102."C\folder2\ "

Image
ImageID int
IPID int (fk to the above table)
RelativePath string
2001, 101 , "picture\girl.j pg"
2002,101, "pictures\boy.j pg"
3001, 102, "family\mom.jpg "
3002, 102, "family\dad.jpg "

The ImagePath gives you the ability move files, and not have to update a
million rows.

Select ip.Path + i.RelativePath as FullPathName from ImagePath ip join
Image i on ip.IPID = i.IPID

so you'd get back
C:\folder1\pict ure\girl.jpg
C:\folder1\pict ures\boy.jpg
C:\folder2\fami ly\mom.jpg
C:\folder2\fami ly\dad.jpg

That's how I implement it. Esp in a big project where you have a
zillion
images, the ImagePath table allows easier updating.
If you don't need security, I'd keep the files as (real) files ... and
have
paths to them.

But that's me.

Its cheap (compared to pulling it out of the database) to send a url of
a
file that already exists out to your client-browsers.


"Chris" <Ch***@discussi ons.microsoft.c omwrote in message
news:E8******** *************** ***********@mic rosoft.com...
Hi,
I need to store lots of product images. I was thinking of storing the
paths
in the database but overtime it may become cumbersome as I'll be
dealing
with
lots of images.
>
I would need to display both a thumbnail and large versions. The
average
size per image is 400kb and the max display is 1702 by 2542.
>
Would SQL Server be a good alternative?
>
Thanks

May 23 '07 #6

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

Similar topics

699
33681
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro capabilities, unfortunately. I'd like to know if it may be possible to add a powerful macro system to Python, while keeping its amazing syntax, and if it could be possible to add Pythonistic syntax to Lisp or Scheme, while keeping all of the...
125
14652
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from software giant such as Microsoft SQL Server, Oracle, and Sybase? Is PostgreSQL reliable enough to be used for high-end commercial application? Thanks
1
1343
by: bigbob | last post by:
Assume you have a page that has the following three drop down lists List_Of_States (Contains 50 States) List_Of_Counties (Contains a list of counties in the selected state) List_Of_Cities (Contains a list of cities/towns in the selected county) The list of states is static. The entire list of counties would be fairly small (~20 counties per state = ~1000 counties)
1
2969
by: Joe Attardi | last post by:
Hi all, On a form on one of my pages I have two <select> elements, and each one is paired up with a radio button. The idea is to choose an item from one list or the other and select the radio button of the list you want to use. I'm using JavaScript to automatically select the radio button corresponding to a list when you click on the list (using the onclick event handler). Is that the best event to change on, or should this
98
4546
by: tjb | last post by:
I often see code like this: /// <summary> /// Removes a node. /// </summary> /// <param name="node">The node to remove.</param> public void RemoveNode(Node node) { <...> }
4
3026
by: Vince C. | last post by:
Hi all. I can see the standard template library has changed a lot since I begun C++ 10 years ago... Now I'm facing with outputing the members of a struct, say Option, which contains 2 members through ostream. I have defined a vector of Option: struct Option { char* name;
2
16792
yashg
by: yashg | last post by:
I am building a data backup application in C# using Sockets. It has a server component and a client component. The client is going to upload files to the server through TCP sockets. I've got all figured out and have been able to transfer files between client and server. Now I have some doubts about which is the best method to transfer a file? Option 1 - I use the built in Socket.BeginSendFile (I am using async calls) to transfer a file. Option 2...
184
6961
by: jim | last post by:
In a thread about wrapping .Net applications using Thinstall and Xenocode, it was pointed out that there may be better programming languages/IDEs to use for the purpose of creating standalone, single executable apps. My goal is to create desktop applications for use on Windows XP+ OSs that are distributed as single executables that do not require traditional install packages to run. I would like to use a drag and drop UI development...
10
1711
by: timor.super | last post by:
Hi all, Imagine I've an array of int : int anArray = new int; I want to extract all the integer that are superior to 500 I can do :
2
1358
by: Stewart Robert Hinsley | last post by:
I had revised some of my web pages 1) generate content from a CSV file using PHP 2) use PHP classses for ease of maintenance. I was looking at one of the scripts yesterday, as pages using the script seem to be rather sluggish (it doesn't help that the CSV file is 0.5Mb), and found that it was only working by accident.
0
7954
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
7882
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8260
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8250
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5416
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3908
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2391
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1490
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1222
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.