472,342 Members | 1,273 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,342 software developers and data experts.

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
uploaded.
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 + "\\" +
DirectoryName))
{
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 + "\\" +
ImageName);
System.Drawing.Bitmap ThumbNail;

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

Thanks,
Ron Vecchi

Nov 17 '05 #1
1 2042
Hi Ron,

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

ThumbNail.Save("c:\test\result.jpg",
System.Drawing.Imaging.ImageFormat.Jpeg);

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

Hope this help,

Luke
Microsoft Online Support

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

Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Alex Hopson | last post by:
I'm using the code below to loop through some images and resize each image twice, once to create a thumbnail and once to create a small image. ...
9
by: Bryan R. Meyer | last post by:
Hello Everyone, The problem of browser resizing has become an issue for me. While redesigning my webpage, I set the left and right margins to be...
2
by: Harry Haller | last post by:
I am trying to display one image on top of another. The background image is: 16 Kbytes, width: 735 px, height: 958 px. It has a single color...
2
by: marvin | last post by:
Hi, I am trying to display images in a repeater from a SQL database and do some transformations on the image prior to displaying them (such as...
6
by: neverstill | last post by:
hi- So I wrote this nice little page that will allow the managers to add images to the products table. Without too many details to confuse...
0
by: Keldair via DotNetMonster.com | last post by:
Hello all, I am working with some barcode images using a TTF (True Type Font). I know it is not the best method, but it is what I have available...
9
by: dli07 | last post by:
Hello, I'm trying to convert a piece of code that creates a dynamic vertical resizing bar in a table from internet explorer to firefox. It's...
5
matheussousuke
by: matheussousuke | last post by:
Hello, I'm using tiny MCE plugin on my oscommerce and it is inserting my website URL when I use insert image function in the emails. The goal...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.