有什么方法可以使用 ImageSharp 从 .net core2 中的一些 jpeg 创建 gif 吗?
我可以使用 Magick.Net 从一些 jpeg 创建 gif,但它在 Linux 上不起作用。
我想在 Ubuntu 14 上执行此操作。
EDIT
我可以使用 ImageSharp 从 Jpeg 创建 Gif。这是我的源代码:
var ite = fsArray.GetEnumerator(); // fsArray is FileStream Array
ite.MoveNext();
using (var image1 = Image.Load(ite.Current.Name))
{
image1.Mutate(x => x.Resize(width, height));
// loop
while (ite.MoveNext())
{
using (var image2 = Image.Load(ite.Current.Name))
{
image2.Mutate(x => x.Resize(width, height));
image2.Frames.First().MetaData.FrameDelay = interval;
image1.Frames.AddFrame(image2.Frames.First());
}
}
msGif = new FileStream("result.gif", FileMode.CreateNew);
var gifEnc = new SixLabors.ImageSharp.Formats.Gif.GifEncoder();
image1.Save(msGif, gifEnc);
msGif.Close();
}
- 加载您的两张图像
- 添加第二个图像中的第一帧(缩放后)作为
ImageFrame<T>
to the Frames
第一个图像上的属性。
- 将输出图像另存为 gif。
将图像保存为 gif 时会自动进行量化。目前将为每个帧生成一个单独的调色板。
using (var image1 = Image.Load(instream1))
using (var image2 = Image.Load(instream2))
{
image2.Mutate(x => x.Resize(image1.Width, image1.Height));
image1.Frames.AddFrame(image2.Frames[0]);
image1.Save(outstream, new GifEncoder());
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)