Resize and Upload Images to SQL Server 2005

  • Thread starter Thread starter bungle
  • Start date Start date
B

bungle

Hi

Would anyone be able to offer advice on how they would upload images
to SQL Server 2005 so that if they are too big the system will
automatically resize them first? Obviously you need to get hold of the
image first so do you store them to a temporary location first etc.???
This will be a web app.

Any advice/discussion would be very helpful.

Thanks

Dave
 
Would anyone be able to offer advice on how they would upload images
to SQL Server 2005 so that if they are too big the system will
automatically resize them first? Obviously you need to get hold of the
image first so do you store them to a temporary location first etc.???
This will be a web app.

Define "too big" and "automatically". Do you want .NET to detect "too
big" and without any intervention on your part, do the resizing? Or do
you simply mean you want to write the code to detect that case and resize
when necessary? If the latter, read on...

I don't know about the "web" and "SQL" aspects of your question. But
resizing the image is easy. Depending on the quality of the resizing you
want, you can just create a new Bitmap instance based on an existing Image
(which in this case would be the original Bitmap), providing a new size.
The image will be scaled for you. If you want better-quality resizing,
you need to create the new Bitmap with the size you want, but then create
a Graphics from the new Bitmap (Graphics.FromImage()) set the
interpolation mode to whatever value you want (the
Graphics.InterpolationMode property), and then draw the original bitmap
into the new bitmap (Graphics.DrawImage()).

If you already know how to get the bitmap instance, and you already know
how to save that image to a SQL database, then the above is really all you
need. If you need all that other stuff too, someone else will have to
answer that. :)

Pete
 
If you store images in varbinary fields, you should not worry about any
resizing and big issues

See samples for BLOB manipulation in SQL Books Online.

HTH
Alex
 
If you store images in varbinary fields, you should not worry about any
resizing and big issues

I disagree. First of all, clearly the OP is concerned, and his concerns
should not be dismissed without at least trying to understand why he has
them.

Second, a database has to be stored somewhere. The data has to be
transferred somehow. The larger the data is, the more space the database
takes up and the slower it is to move the data around (whether that's to
update the database, return results to a client, or doing maintenance on
the database). Reducing data size is quite often a very legitiate and
very important goal.

Pete
 
If original concerns are not addressed, most probably original poster will
add some details to clarify the issue.
 
Back
Top