On Thu, 07 Jun 2007 07:12:47 -0700, bungle <bu****@wizardb uy.comwrote:
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.FromI mage()) set the
interpolation mode to whatever value you want (the
Graphics.Interp olationMode property), and then draw the original bitmap
into the new bitmap (Graphics.DrawI mage()).
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