Connecting Tech Pros Worldwide Forums | Help | Site Map

Adding images to the database

Earl
Guest
 
Posts: n/a
#1: Nov 30 '06
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.



Mike C#
Guest
 
Posts: n/a
#2: Dec 1 '06

re: Adding images to the database


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" <brikshoe@newsgroups.nospamwrote in message
news:%23eO12zNFHHA.3608@TK2MSFTNGP03.phx.gbl...
Quote:
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.
>

Cor Ligthert [MVP]
Guest
 
Posts: n/a
#3: Dec 1 '06

re: Adding images to the database


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" <brikshoe@newsgroups.nospamschreef in bericht
news:%23eO12zNFHHA.3608@TK2MSFTNGP03.phx.gbl...
Quote:
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.
>

Earl
Guest
 
Posts: n/a
#4: Dec 1 '06

re: Adding images to the database


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" <MikaelGustavsson@discussions.microsoft.comwrote in
message news:2497ED03-EA23-4DF6-8581-A2E0382CAFE7@microsoft.com...
Quote:
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:
>
Quote:
>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" <brikshoe@newsgroups.nospamschreef in bericht
>news:%23eO12zNFHHA.3608@TK2MSFTNGP03.phx.gbl...
Quote:
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.
>
>>
>>
>>

Closed Thread