473,394 Members | 1,878 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,394 software developers and data experts.

Adding images to the database

Looking for an idea here. I've got a .Net app connecting to SQL2005 where I
allow users to add pictures to the database. But I don't want them adding
gigantic images, so I'm looking for an idea on how to control how big of an
image they might add. I'm not interested in simply saving a pointer to a
file here.
Nov 30 '06 #1
3 1442
varbinary (max) would automatically limit them to 2 GB size, but your best
bet might be to check the size on the client side if you want to limit them
to say 10 MB or something. If you send it to the server first, someone
might have just spent all that time uploading a 100 MB file only to have it
error on them. That's a waste of time and bandwidth. If you want to ensure
that, for instance, your developers can't work their way around the system
and bypass the client app to insert larger files you might look into
triggers as well.

"Earl" <br******@newsgroups.nospamwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
Looking for an idea here. I've got a .Net app connecting to SQL2005 where
I allow users to add pictures to the database. But I don't want them
adding gigantic images, so I'm looking for an idea on how to control how
big of an image they might add. I'm not interested in simply saving a
pointer to a file here.

Dec 1 '06 #2
Earl,

the most easiest way is in my idea to use the thumbnail.

In this sample is that used.
Dim fo As New OpenFileDialog
If fo.ShowDialog = DialogResult.OK Then
PictureBox1.Image = PictureBox1.Image.FromFile(fo.FileName)
Dim Thumbnail As System.drawing.Image = _
PictureBox1.Image.GetThumbnailImage(32, 32, Nothing, New IntPtr)
PictureBox2.Image = Thumbnail
End If
I hope this helps,

Cor
"Earl" <br******@newsgroups.nospamschreef in bericht
news:%2****************@TK2MSFTNGP03.phx.gbl...
Looking for an idea here. I've got a .Net app connecting to SQL2005 where
I allow users to add pictures to the database. But I don't want them
adding gigantic images, so I'm looking for an idea on how to control how
big of an image they might add. I'm not interested in simply saving a
pointer to a file here.

Dec 1 '06 #3
Thanks to all, Mike, Mikael and Cor. Looks like I'm going to resize on the
client side using the new Width and Height. I can certainly see uses for
thumbnails though.

"Mikael Gustavsson" <Mi**************@discussions.microsoft.comwrote in
message news:24**********************************@microsof t.com...
Hi!

If you wish for the image to be anything else than a thumbnail I would
suggest that you resize the image instead of using the GetThumbnailImage.
Resizing the image is pretty simple Here is an example.

Bitmap bmp = new Bitmap(uploadedImage, newWidth, newHeight);
bmp.Save(myStream, System.Drawing.Imaging.ImageFormat.Png)

You can also use encoding parameters to save the image in order to change
compression and such. Then just remember that you can user
System.Drawing.Imaging.ImageFormat.<imagetype>.Gui d to get the correct
guid
for the encoder.

Good luck!

//Micke

"Cor Ligthert [MVP]" wrote:
>Earl,

the most easiest way is in my idea to use the thumbnail.

In this sample is that used.
Dim fo As New OpenFileDialog
If fo.ShowDialog = DialogResult.OK Then
PictureBox1.Image = PictureBox1.Image.FromFile(fo.FileName)
Dim Thumbnail As System.drawing.Image = _
PictureBox1.Image.GetThumbnailImage(32, 32, Nothing, New IntPtr)
PictureBox2.Image = Thumbnail
End If
I hope this helps,

Cor
"Earl" <br******@newsgroups.nospamschreef in bericht
news:%2****************@TK2MSFTNGP03.phx.gbl...
Looking for an idea here. I've got a .Net app connecting to SQL2005
where
I allow users to add pictures to the database. But I don't want them
adding gigantic images, so I'm looking for an idea on how to control
how
big of an image they might add. I'm not interested in simply saving a
pointer to a file here.



Dec 1 '06 #4

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

Similar topics

3
by: mark | r | last post by:
ok, so i now know how to add, edit, delete and search for products (havent figured out categorisation out yet tho) - how do i upload an image and save the file name to the database as part of the...
3
by: Chris Minchin | last post by:
Hi there, I am a bit of a newboy to access I have a database which I wish to have pictures. for example: record one will have data and a picture, record two will have different data and a diferent...
10
by: Neo Geshel | last post by:
I am seeking to hand-roll my own blog in ASP.NET 2.0 and SQLExpress 2005. Why? Because I can. Because I will gain experience. The one thing that has me stumped at square one is inline images....
9
by: Neo Geshel | last post by:
I have strip-mined, strip-searched, and completely exhausted the Internet (up to the 30th page on Google, with 100 results per page!!), all without finding an answer to my question AS TO WHY IT...
3
by: Earl | last post by:
Looking for an idea here. I've got a .Net app connecting to SQL2005 where I allow users to add pictures to the database. But I don't want them adding gigantic images, so I'm looking for an idea on...
10
by: eholz1 | last post by:
Hello Members, I am setting up a photo website. I have decided to use PHP and MySQL. I can load jpeg files into the table (medium blob, or even longtext) and get the image(s) to display without...
1
by: colmkav | last post by:
Hi, when I try to add a logo to my form I click on the unbounded object frame and then browse for tje location of my logo. I open the .bmp file but get an error claiming "OLE object isnt...
3
by: najimou | last post by:
Hi everyone I will be having a split database, running on 2 computers via mapped drive. computer "A" will have one front end and the back end located in c: \mydatabse 2 tables have links to...
7
by: Keith Hughitt | last post by:
Hi all, I am having trouble preloading images in a javascript application, and was wondering if anyone had any suggestions. Basically I have a bunch of images stored in a database as BLOBs. At...
1
by: swethak | last post by:
Hi, I am desiging the calendar application for that purpose i used the below code. But it is for only displys calendar. And also i want to add the events to calendar. In that code displys the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.