c# - Reduce size of image after Scan? -


I scan the file and save it on my path:

  scan the public imagefile () {Var device = this._deviceInfo.Connect (); Var item = device.edit [1]; Imagefile = (imagefile) item.Transfer (FormatID.wiaFormatJPEG); Return image file; } Protected Zero btnscan_Click (Object Sender, EventArgs e) {foreach (Scanner Object In Object Scanner) {if (ddlSelectDevice.SelectedItem.ToString (.) Equals (scanner.ToString ())} // ddlSelectDevice as // d = scanner .SelectedIndex; Var device = scanners as scanners; If (device == faucet) {return; } Var image = device.Scan (); Var path = "~ / scanner / scan.jpeg"; If (File.Exists (Server.MapPath (Path))) {File.Delete (Server.MapPath (Path)); } Image.SaveFile (Server.MapPath (Path)); break; }}}  

I can convert this image into a byte in the database:

  byte [] image2Byte () {string filePath = null; Byte [] bytes = null; If (File.Exists (Server.MapPath ("~ / scanner / scan.jpeg")) {FilePath = Server.MapPath ("~ / scanner / scan.jpeg"); Return Bytes = File Readelbates (filepath); } And {filePath = Server.MapPath ("~ / scanner / none.jpg"); Return Bytes = File Readelbates (filepath); }}  

But my images are usually large size (up to 400KB) and the problem is on the load. How do I reduce the image size?

You can use to reduce the quality of the JPEG file. For most use cases 80% of the quality is invaluable. Using

  (ImageFactory imageFactory = New ImageFactory (preserveExifData: true)) {imageFactory.Load (instream). Quality (80) Save (outstream); }  

Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -