c# - Convert png to jpeg (quality of image after conversion) -
c# - Convert png to jpeg (quality of image after conversion) -
i have 10000 png files of product images. later learnt product images in production jpeg , hence need convert new 10000 png files jpeg. happen quality of image if alter extension png jpeg?
i work on c#/sql server environment , should use
system.drawing.image image1 = system.drawing.image.fromfile(@"c:\test.png"); // save image in jpeg format. image1.save(@"c:\test.jpg", system.drawing.imaging.imageformat.jpeg);
any thoughts on this?
jpeg, unlike png, lossy format. there decrease in quality.
you can create sure it's unnoticable or unnoticable using highest possible quality level when saving jpeg.
taken msdn:
// bitmap. bitmap bmp1 = new bitmap(@"c:\testphoto.jpg"); imagecodecinfo jgpencoder = getencoder(imageformat.jpeg); // create encoder object based on guid // quality parameter category. system.drawing.imaging.encoder myencoder = system.drawing.imaging.encoder.quality; // create encoderparameters object. // encoderparameters object has array of encoderparameter // objects. in case, there 1 // encoderparameter object in array. encoderparameters myencoderparameters = new encoderparameters(1); myencoderparameter = new encoderparameter(myencoder, 100l); myencoderparameters.param[0] = myencoderparameter; bmp1.save(@"c:\testphotoqualityhundred.jpg", jgpencoder, myencoderparameters);
also maintain in mind jpeg format not save alpha channel of image.
this related question deals default quality level .net uses: what quality level image.save() utilize jpeg files?
c#
Comments
Post a Comment