asp.net - .Net image crop resulting in files much larger than original -


i using code such following crop images:

dim oimg system.drawing.image = system.drawing.image.fromfile(ssrc)  'prep new image dim ocanvas system.drawing.bitmap select case oimg.pixelformat     case 198659, 197634, 196865, 65536 'indexed formats (as found in gifs) cant used make graphic object         ocanvas = new system.drawing.bitmap(w, h, pixelformat.format32bppargb)     case else 'use src img's pixel format         ocanvas = new system.drawing.bitmap(w, h, oimg.pixelformat)              end select ocanvas.maketransparent()   dim ographic graphics = graphics.fromimage(ocanvas) ographic.interpolationmode = system.drawing.drawing2d.interpolationmode.highqualitybicubic ographic.smoothingmode = system.drawing.drawing2d.smoothingmode.highquality ographic.pixeloffsetmode = system.drawing.drawing2d.pixeloffsetmode.highquality ographic.compositingquality = system.drawing.drawing2d.compositingquality.highquality ographic.clear(color.transparent) ographic.drawimage(oimg, new rectangle(0, 0, w, h), x, y, w, h, graphicsunit.pixel)   select case stgtfileext     case "jpg"         dim jpgencoder imagecodecinfo = getencoder(imageformat.jpeg)         dim myencoder system.drawing.imaging.encoder = system.drawing.imaging.encoder.quality         dim myencoderparams new encoderparameters(1)         dim myencoderquality new encoderparameter(myencoder, ctype(98l, int32)) '98%         myencoderparams.param(0) = myencoderquality         ocanvas.save(stgt, jpgencoder, myencoderparams)     case "png", "gif"         ocanvas.save(stgt, system.drawing.imaging.imageformat.png)     case "tiff", "tif"         ocanvas.save(stgt, system.drawing.imaging.imageformat.tiff)     case else         ocanvas.save(stgt, system.drawing.imaging.imageformat.png) end select 

specifically cropping .jpg source files, ending cropped images 5-8 times filesize un-cropped original.

for example, can input image is, say, 800kb in size, , crop middle half of new image, which, when saved on 5mb.

if don't leave jpeg quality @ 95% or higher, image lower in quality original still same or more in filesize.

what want image same quality original. code causes huge increase in size, cropped section of original?

found bug... unrelated image processing. bug in final case statement chooses encoder. code captures extension had "." character present, case names didn't, thus, automatically hitting else case, defaults image type png, of course lossless format, , has higher file size in general


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -