【问题标题】:save a JPEG in progressive format [closed]以渐进格式保存 JPEG [关闭]
【发布时间】:2013-12-09 23:20:00
【问题描述】:

已经在这个帖子上提出了一个类似的问题:

Save JPG in progressive format

但是,标记的答案基本上是说做不到。但是,考虑到它是使用其他软件完成的,这绝对是 C# 可以做到的。

有什么办法可以做到吗?

【问题讨论】:

标签: c# asp.net encoding jpeg


【解决方案1】:

Magick.NET 可以用这样的代码做到这一点

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");
}

您可以找到更多详细信息here

【讨论】:

  • 链接到 ImageMagick 库,它不是本地的。
  • 不是,但从较早的问题中可以清楚地看出,目前没有对 stackoverflow.com/a/2268376/537682 的原生支持。在那种情况下,我看不出重新提出这个问题的原因。
  • @CharlieKilian 通过“本机”,我是直接从 C# 代码中理解的,而不是说使用外部可执行文件。我知道这可能具有误导性,我现在更新了标题。
  • @ZoltánKocsán 谢谢!刚刚试了一下,效果很好!
猜你喜欢
  • 2011-01-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-01-14
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多