_
Public Sub Save(ByVal b As Bitmap, ByVal FileName As String, ByVal Compression As Long, ByVal MimeType As String)
Dim Params As EncoderPara
As far as I can tell, it's not supported. I have tried code suggested here and here and arrived at 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, it still saves a regular baseline JPEG. I have tried any combination of either setting and their alternative settings (non-interlaced and non-progressive), and haven't seen any difference at all in the resulting image file.
I haven't found any response from anyone saying that they have actually managed to save a progressive JPEG in .NET.
Both the ScanMethodInterlaced
and RenderProgressive
parameter values are described only as "Not used in GDI+ version 1.0." in
the documentation.
I suppose to use 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 by such way:
jpegtran -copy none -optimize input.jpg output.jpg