Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

save a JPEG in progressive format [closed]

A similar question has already been asked on this thread:

Save JPG in progressive format

However, the answer marked is basically saying that it can't be done. However, considering it is done using other software, it definitely is something which C# can do.

Is there any way this can be done?

like image 249
Karl Cassar Avatar asked Nov 05 '13 11:11

Karl Cassar


People also ask

Should I save JPEG as baseline or Progressive?

With baseline JPEG, your users see a large white space on the screen or a loading circle spinning until the image has finished loading. With progressive JPEG, visitors can already see the entire image at first sight. Although it's blurry, they can still understand what's in the image.

How do I change a JPEG from JPEG to baseline in Progressive?

Opening the progressive JPG in any image editing program and then saving it as JPG should convert the file. So if you use Image Events in Applescript (which is just a front end to sips) to open the file and then save it choosing JPG as the format that should convert it.

When saving JPEG What is Progressive?

A progressive JPEG image is encoded differently than a standard or baseline JPEG image. It loads in successive waves until a clear picture is formed. This can improve a website's performance as the images seems to be loading faster.


1 Answers

Magick.NET can do it with a code like this

using (MagickImage image = new MagickImage("input.png"))
{
  // Set the format and write to a stream so ImageMagick won't detect the file type.
  image.Format = MagickFormat.Pjpeg;
  using (FileStream fs = new FileStream("output.jpg", FileMode.Create))
  {
    image.Write(fs);
  }
  // Write to .jpg file
  image.Write("PJEG:output.jpg");
  // Or to a .pjpeg file
  image.Write("output.pjpg");
}

You can find more details here.

like image 135
Zoltan Kochan Avatar answered Oct 10 '22 03:10

Zoltan Kochan