c# - To reduce the size of image when uploading -


I am uploading a document in the code below. My goal is that it is an image document, 20 Kb.Pls help me do this.

String UploadPath = Configuration Manager. AppSettings ["SearchFolder"]; String strUploadpath = uploadpath. Terminal ("\\". ToCharArray ()) + "\\" + strClientName + \ "" + strDocumentFolder + "\" "DirectoryInfo dInfo = New Directory Info (strUploadpath); If (! DInfo.Exists) {dInfo.Create ();} (If the file is uploaded.filame! = Null & amp; documentpload.filename! = String. Empty) {document plus.avesave ((aruploadpath) + documentpload.philname); size of a shape depends on some factors (size , Resolution, Format, Compression, etc.).

Example

  // Dastavejhuplod. Shejenas ((Saruplodpeth) + Dastavejuplodkfailnam); Stream stream = document plus.posted file.inputstream; Bitmap source = new bitmap (stream); Bitmap target = new bitmap (source width, source.high); Graphics G = Graphics. Framesize (target); Encoderparameters e; G.CompositingQuality = Compositing Quality High speed; & Lt; - Here g.InterpolationMode = InterpolationMode.Low; & Lt; - Rectangle Rectangle Here = New Rectangle (0, 0, Source Width, Source High.); G. Drymage (source, Rick compression); E = new encoder parameter (2); E. Param [0] = new encoder parameter (encoder quality, 70); & Lt; - Here 70% quality e. Param [1] = new encoder parameter (encoder. Compression, (long) encoder value. Compression LZW); & Lt; - Target here Save (New Name, GetEncoderInfo ("image / jpeg"), e); G.Dispose (); Target.Dispose (); Public static ImageCodecInfo GetEncoderInfo (string sMime) {ImageCodecInfo [] objEncoders; ObjEncoders = ImageCodecInfo.GetImageEncoders (); For (iLoop ++) (iLoop + iLoop .mimeType == sMime) objEncoders [iLoop];} return tap;}  Code> 

Hope this helps.


Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -