Click here to Skip to main content
12,691,789 members (27,721 online)
Rate this:
Please Sign up or sign in to vote.
See more: image WebAPI ASP.NET4 , +
Hi all i am working on webapi i need to optimize the images from folder

here i Had Uploaded images into one folder before

uploading in to the destination folder i need to decrease the image size in KB of total images

here i am optimizing a single image in to 3 different sizes' (large, thumbnail,medium)' but image sizes are increased and saved in one folder now i need to optimize those images could u plz help me how could i do that. actually i am new to webapi. any body could have any idea please help me but one thing i need to do this manually thankyou in advance
Posted 25-Sep-12 22:07pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

If you want to reduce the uploaded image size only , and retain its quality this link will be helpful

how to resize image without losing image quality or how to reduce image file size without losing quality using
ghousebasha 26-Sep-12 6:44am
yes but it is for only i need to be work in webapi thankyou for time spent for me if ane other help ploease help me
ghousebasha 26-Sep-12 12:06pm
thank for your answer i got it
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

as of above question no problem i think it is increasing with quality option you just have to do simple just decrease the quality make upload image and check it once

public static void Resize(string original, string output, int width, int height)
            using (var image = Image.FromFile(original))
            using (var thumbnail = new Bitmap(width, height))
            using (var graphics = Graphics.FromImage(thumbnail))
                graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
                graphics.SmoothingMode = SmoothingMode.HighQuality;
                graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
                graphics.CompositingQuality = CompositingQuality.HighQuality;

                graphics.DrawImage(image, 0, 0, width, height);

                ImageCodecInfo[] info = ImageCodecInfo.GetImageEncoders();
                EncoderParameters encoderParameters;
                encoderParameters = new EncoderParameters(1);
                encoderParameters.Param[0] = new EncoderParameter(Encoder.Quality, 80L);
                thumbnail.Save(output, info[1], encoderParameters);

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170117.1 | Last Updated 11 Oct 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100