473,480 Members | 4,939 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

want to compress image in asp.net & c#

43 New Member
string stFileName = "abc";
string stFullFilePath = Server.MapPath("images/" + stFileName + ".jpg");
System.Drawing.Image i = System.Drawing.Image.FromFile(stFullFilePath);

EncoderParameters eps = new EncoderParameters(1);
eps.Param[0] = new EncoderParameter( Encoder.Quality, 40 );

ImageCodecInfo ici = GetEncoderInfo("image/jpeg");//this line give error, "The name 'GetEncoderInfo' does not exist in current context"


i.Save(stFullFilePath, ici, eps);


event though i use same code difine on msdn, but got same error, unable to GetEncoderInfo("image/jpeg");

remove this error

or tell me some other technique to compress my jpeg images
Aug 1 '07 #1
2 9350
Plater
7,872 Recognized Expert Expert
These are very simple errors that the dev enviroment tells you how to fix.
You are probably just missing a namespace reference.

Click on the offending word and hover your mouse there, if you have spelled it correctly (capitalization counts!) then a little red underline will appear below the last character, hover your mouse over that and see the options.

If that does not appear, check the help on that command and find out what
namesapce you need to include to use it.
Aug 1 '07 #2
Roberto Videla
1 New Member
private ImageCodecInfo getEncoderInfo(string mimeType)
{
// Get image codecs for all image formats
ImageCodecInfo[] codecs = ImageCodecInfo.GetImageEncoders();

// Find the correct image codec
for (int i = 0; i < codecs.Length; i++)
if (codecs[i].MimeType == mimeType)
return codecs[i];
return null;
}

I hope that is helpful
Jun 22 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
6303
by: Mike Albrecht | last post by:
Hello Group, Pardon any cross posting. We wanted to replace the standard submit buttons on a web form with custom 'image' buttons. Here's the code I used: <input type="image"...
3
2403
by: Edward | last post by:
Thanks to Bob Powel (http://www.bobpowell.net/onebit.htm) I'm able to compress an image. However, this method takes a long time to compress an image. Does anyone know a quicker way? (The images I...
8
2589
by: Jef Driesen | last post by:
I'm implementing some image processing algorithms in C++. I created a class called 'image' (see declaration below), that will take care of the memory allocations and some basic (mathematical)...
4
28134
by: Ed Landau | last post by:
In VB6.0, I can put an image on a form and assign it's .picture property at run-time. In VBA (within MS Access), when I put down an image control on a form, it asks me for the source to the image...
0
945
by: ivan.dm | last post by:
Hi Body, Can I set an image from file into DrawArea, so I can resize and drawing any object over its image? any tips or idea? Thanks Ivan
4
1615
by: active | last post by:
I want an image in a tablecell to be scaled to fit the cell without distorting the image. I don't know what the image aspect ratio will be. Sometimes I'd expect to see the width fit the cell...
0
1130
by: lhoracio | last post by:
Hi, I've got a small app in VB6 with MySQL. Works fine, but I found I would need to embedd some images on text displayed in a RTF control. I have no problem in pasting it to the control....
6
2207
by: mohammedsiddig | last post by:
Hello php programmer ! how i can compress image and storage it on oracle ? the compress must reduce the original size of the image to more than half of original size
1
2041
by: abdul hanan | last post by:
I want to read image form c and compress it on turbo c. #include<stdio.h> #include<conio.h> void main() { FILE*fptr; fptr=fopen("D:\\abc.jpg","r"); printf("%c",getc(fptr)); }
0
6905
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7041
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7080
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...
1
6736
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...
1
4772
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...
0
2980
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1299
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 ...
1
561
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
178
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...

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.