469,648 Members | 1,407 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,648 developers. It's quick & easy.

Resizing Images and getting a black background and larger file size

I am using asp.net to upload an image and then perform resizing on it and
saving the different sizes to file.
The resized images were coming up and being displayed in the bowser fine but
the image sizes are a lot bigger(in file size) than the actual image being
The actual image being uploaded was around 22000bytes
The smaller resized image is 120000bytes

Also on the web when the resized image is displayed it starts out with a
black background and progressivly shows the image
I also downloaded some of the resized images and tried opening them in
photoshop and I got an error saying it couldn't open them because of an
unknown jpeg marker.
I posted my code for resizing the image below, mabey I went about it wrong.
Any ideas


this.CreateSpecialRotator(ImageName,"SpecialProduc ts",180,180);

private void CreateSpecialRotator(string ImageName,string DirectoryName,int
Width, int Height)
if(! System.IO.Directory.Exists(this.ImageUploadDirecto ryPath + "\\" +
System.IO.Directory.CreateDirectory(this.ImageUplo adDirectoryPath +
"\\" + DirectoryName);

if(File.Exists(this.ImageUploadDirectoryPath + "\\" + ImageName))
System.Drawing.Image i =
System.Drawing.Image.FromFile(this.ImageUploadDire ctoryPath + "\\" +
System.Drawing.Bitmap ThumbNail;

if(i.Width > 180)
ThumbNail = new
Bitmap(i,180,this.CalculateHeight(i.Height,i.Width ,180));
ThumbNail = new Bitmap(i);
ThumbNail.Save(this.ImageUploadDirectoryPath + "\\" + DirectoryName
+ "\\" + ImageName);

Ron Vecchi

Nov 17 '05 #1
1 1954
Hi Ron,

You may try to sepcify the image's format property when saving it, for


Based on my test, the result jpg file will be smaller than source file with
above code.

Hope this help,

Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no

Nov 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Alex Hopson | last post: by
9 posts views Thread by Bryan R. Meyer | last post: by
2 posts views Thread by Harry Haller | last post: by
6 posts views Thread by neverstill | last post: by
reply views Thread by Keldair via DotNetMonster.com | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.