Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Image Upload

Status
Not open for further replies.

transparent

Programmer
Sep 15, 2001
333
GB
I have created an image upload usercontrol that allows me to upload an image. When an image has been uploaded it throws an event and the image is passed as an image object as an arguement of the event.


This works really well and integrates with my site very well.

I re-size the image to 300*300 (cropping where necessary).

The outputed image is always huge (in terms of filesize) - at least 200k.

Has anybody else had this problem? How did you solve it?
 
Some more information about the image format used, the method (code) of resizing/cropping would be useful to answer this.

Regards, Ruffnekk
---
Is it my imagination or do buffalo wings taste just like chicken?
 
I dont have the code with me, but essentially, I upload the file, create a graphics object using:


1) Create a bitmap object
2) Create a graphics drawing surface using this bitmap with Graphics.FromImage
3) I then draw my uploaded image onto this surface using Graphics.DrawImage - I pass as a parameter a rectangle object of the dimensions I require to crop the image
4) I then save the image using the save method of the bitmap.

Is there anything here I am doing incorrectly.

I assume it is the parameters of the save method that are important here?

 
You should use an overloaded definition of the Save method of the Image object:

Image.Save(filename As String, format As ImageFormat)

If you choose a different ImageFormat you get different results in regards to the filesize. If your images are photo's, the best format would be Jpeg in respect to quality/filesize ratio. If you would use bmp (bitmap) the file size would be much larger for the same photo.

So I would suggest using

Image.Save("myfilename.jpg", ImageFormat.Jpeg)

Regards, Ruffnekk
---
Is it my imagination or do buffalo wings taste just like chicken?
 
The thing is I am actually saving using this method:

Image.Save("myfilename.jpg", ImageFormat.Jpeg)

And yet the images are still huge!

Are there any other settings I should be aware of?
 
Is the canvas size of the image really 300 x 300 pixels?

Regards, Ruffnekk
---
Is it my imagination or do buffalo wings taste just like chicken?
 
That could be it. If VS.NET saves a Jpeg with default settings of maximum quality the filesize is consisting with my findings in Photoshop.

Regards, Ruffnekk
---
Is it my imagination or do buffalo wings taste just like chicken?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top