473,544 Members | 2,037 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.CreateSpec ialRotator(Imag eName,"SpecialP roducts",180,18 0);

private void CreateSpecialRo tator(string ImageName,strin g DirectoryName,i nt
Width, int Height)
{
if(! System.IO.Direc tory.Exists(thi s.ImageUploadDi rectoryPath + "\\" +
DirectoryName))
{
System.IO.Direc tory.CreateDire ctory(this.Imag eUploadDirector yPath +
"\\" + DirectoryName);
}

if(File.Exists( this.ImageUploa dDirectoryPath + "\\" + ImageName))
{
System.Drawing. Image i =
System.Drawing. Image.FromFile( this.ImageUploa dDirectoryPath + "\\" +
ImageName);
System.Drawing. Bitmap ThumbNail;

if(i.Width > 180)
{
ThumbNail = new
Bitmap(i,180,th is.CalculateHei ght(i.Height,i. Width,180));
}
else
{
ThumbNail = new Bitmap(i);
}
ThumbNail.Save( this.ImageUploa dDirectoryPath + "\\" + DirectoryName
+ "\\" + ImageName);
i.Dispose();
ThumbNail.Dispo se();
}
}

Thanks,
Ron Vecchi

Nov 17 '05 #1
1 2113
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.ImageFo rmat.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
2685
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. The page stops loading around the 38th image out of 40+. Not always the same place but it's either 38th or 39th image, which I find strange as it's not consistent. At first I thought it was a...
9
32028
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 auto so that my content would be centered. However, there are images that I used absolute positioning in order to place them in the appropriate location on my page. When I do a browser resize,...
2
10998
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 redbrick image on a transparent background. The foreground image is: 3 Kbytes, width: 372 px, height: 91 px. It has a single color black image on a transparent background. It should appear on the...
2
5220
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 thumbnail with a shadow). The problem is I can't seem to get the data passed to the handler. The following is the code that I have so far. In the ViewPics.aspx file I have...
6
1921
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 everything, basically what I'm doing is: getting an Image from there I'm creating a new Bitmap(Image, int w, int h); then I'm saving that bitmap various encoder quality values.
0
986
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 at the moment. I have everything working all up to printing the barcode to an image file, I have code that works for that but the resolution is far too low for recognition from a barcode scanner...
9
5275
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 based on a post from http://blogs.crankygoblin.com/blogs/geoff.appleby/pages/50712.aspx. I've also read the post on this topic by bggraphics, but he doesn't arrive at a final result. The main problem I...
5
13314
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 is: Make it send the email with the URL http://mghospedagem.com/images/controlpanel.jpg instead of http://mghospedagem.comhttp://mghospedagem.com/images/controlpanel.jpg As u see, there's the...
0
7437
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7781
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7389
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7717
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5928
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5306
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
1
1848
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
993
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
677
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.