Save JPG in progressive format

<Extension()> _ Public Sub Save(ByVal b As Bitmap, ByVal FileName As String, ByVal Compression As Long, ByVal MimeType As String) Dim Params As EncoderParameters = New EncoderParameters(2) Dim CodecInfo As ImageCodecInfo = GetEncoderInfo(MimeType) Params.Param(0) = New EncoderParameter(Encoder.RenderMethod, EncoderValue.RenderProgressive) Params.Param(1) = New EncoderParameter(Encoder.Quality, Compression) b.Save(FileName, CodecInfo, Params) End Sub 

this does not work. It does not persist as progressive. How can I do this, and possibly also indicate nr passes. ??

+7
html image compression jpeg
source share
2 answers

As far as I can tell, it is not supported. I tried using the code here and here and came to this C # Code:

 using (Image source = Image.FromFile(@"D:\temp\test2.jpg")) { ImageCodecInfo codec = ImageCodecInfo.GetImageEncoders().First(c => c.MimeType == "image/jpeg"); EncoderParameters parameters = new EncoderParameters(3); parameters.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 100L); parameters.Param[1] = new EncoderParameter(System.Drawing.Imaging.Encoder.ScanMethod, (int)EncoderValue.ScanMethodInterlaced); parameters.Param[2] = new EncoderParameter(System.Drawing.Imaging.Encoder.RenderMethod, (int)EncoderValue.RenderProgressive); source.Save(@"D:\temp\saved.jpg", codec, parameters); } 

Setting both interlaced and progressive mode allows you to save the usual basic JPEG. I tried any combination of settings and their alternative settings (without interlacing and without heating) and did not see any difference at all in the resulting image file.

I didn’t find the answer from anyone who said that they actually managed to save progressive JPEG in .NET.

Both ScanMethodInterlaced and RenderProgressive are described only as "Not used in GDI + version 1.0". in the documentation .

+5
source share

I suggest using the jpegtran utility as described in Image Optimization, Part 4: Progressive JPEG ... Hot or Not? article:

 jpegtran -copy none -progressive input.jpg output.jpg 

In addition, you can optimize Haffman tables in this way:

 jpegtran -copy none -optimize input.jpg output.jpg 
+3
source share

All Articles