By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,312 Members | 1,280 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,312 IT Pros & Developers. It's quick & easy.

want to compress image in asp.net & c#

P: 43
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
Share this Question
Share on Google+
2 Replies


Plater
Expert 5K+
P: 7,872
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

P: 1
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

Post your reply

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