[英]How to create Gif .net Core2 , with ImageSharp
Is the any way to create a gif from some jpegs in .net core2 with ImageSharp? 是否可以使用ImageSharp从.net core2中的某些jpeg创建一个gif?
I could create a gif from some jpegs with Magick.Net, but it does'n t work on Linux. 我可以用Magick.Net从一些jpeg创建一个gif,但它在Linux上不起作用。
I wanna do this on Ubuntu 14. 我想在Ubuntu 14上这样做。
EDIT
编辑
I could create a Gif from Jpegs with ImageSharp. 我可以用ImageSharp从Jpegs创建一个Gif。 This is my source code:
这是我的源代码:
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
property on the first image. ImageFrame<T>
到第一个图像上的Frames
属性。 Quantization automatically happens when saving the image as a gif. 将图像另存为gif时会自动进行量化。 Currently a separate palette will be generated for each frame.
目前,将为每个帧生成单独的调色板。
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());
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.