Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: image ImageProcessing webapi , +
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 at 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 at 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
0 Zoltán Zörgő 330
1 Peter Leow 120
2 BillWoodruff 120
3 CHill60 110
4 bling 80
0 Sergey Alexandrovich Kryukov 9,423
1 OriginalGriff 6,891
2 Peter Leow 4,637
3 Zoltán Zörgő 4,304
4 CHill60 2,932

Advertise | Privacy | Mobile
Web01 | 2.8.150129.1 | Last Updated 11 Oct 2012
Copyright © CodeProject, 1999-2015
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