Click here to Skip to main content
Rate this: bad
good
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 21:07pm
Rate this: bad
good
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 asp.net
  Permalink  
Comments
ghousebasha at 26-Sep-12 6:44am
   
yes but it is for only asp.net 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
good
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);
            }
        }
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 470
1 mhegazy94 460
2 Ravi Bhavnani 190
3 Kornfeld Eliyahu Peter 185
4 Shemeemsha RA 160
0 Sergey Alexandrovich Kryukov 7,135
1 OriginalGriff 6,801
2 CPallini 5,350
3 George Jonsson 3,619
4 Gihan Liyanage 2,797


Advertise | Privacy | Mobile
Web04 | 2.8.140922.1 | Last Updated 11 Oct 2012
Copyright © CodeProject, 1999-2014
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