Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Resizing Images and getting a black background and larger file size

Thread Tools

Resizing Images and getting a black background and larger file size

Ron Vecchi
Posts: n/a
I am using 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

Reply With Quote
Posts: n/a
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!
(This posting is provided "AS IS", with no warranties, and confers no

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Resizing a div by resizing its borders Pil (Trustworthy from Experience) Javascript 9 04-21-2009 07:35 AM
Help how to get file size of larger file(>2G)? zou C++ 3 09-29-2007 11:15 PM
pasting images from excel with transparency have a black background Java 0 08-21-2006 02:20 PM
Question: Can I make textarea larger (larger text)? Peter Williams HTML 1 06-03-2005 08:17 AM
20" LCD: setting 4 g Larger text in all Programs? and larger icons lbbss Computer Support 6 04-14-2005 05:46 PM