How to reduce the file size of the image but keeping the quality in C# .net? -


this question has answer here:

just wandering, how reduce file size of image keeping quality in c# .net?

i have following code use save image taken ipad:

bitmap srcbmp = new bitmap(file.inputstream);  int w = srcbmp.width; int h = srcbmp.height; if (srcbmp.width > 2732 && srcbmp.height > 2048) {     w = 2732;     h = 2048; }  sizef newsize = new sizef(w, h); bitmap target = new bitmap(w, h); var destrect = new rectangle(0, 0, w, h);  httpcontext.response.clear(); httpcontext.response.contenttype = "image/jpeg"; using (var graphics = graphics.fromimage(target)) {     graphics.compositingmode = compositingmode.sourcecopy;     graphics.compositingquality = compositingquality.highquality;     graphics.interpolationmode = interpolationmode.highqualitybicubic;     graphics.smoothingmode = smoothingmode.highquality;     graphics.pixeloffsetmode = pixeloffsetmode.highquality;      using (var wrapmode = new imageattributes())     {         wrapmode.setwrapmode(wrapmode.tileflipxy);         graphics.drawimage(srcbmp, destrect, 0, 0, w, h, graphicsunit.pixel, wrapmode);         using (filestream filestream = new filestream(fname, filemode.create))         {             target.save(filestream, system.drawing.imaging.imageformat.jpeg);         }     } } 

the image been saved on 14mb. anyway can keep image quality , reduce file size below 2mb?

i don't think reduction without decresing picture quality possible. can remove metadata image using exif library without reducing picture quality

or if reduction in picture quality can use gid


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -