スキップしてメイン コンテンツに移動

投稿

ラベル(gif)が付いた投稿を表示しています

C#: Extract Gif Frame Images From an Animated Gif Image

I wrote the post for extracting gif frame image from an animated gif image in Java - Java: Extract Gif Images From An Animated Gif Image . In this post, I have tried to do same thing in C# as well :D Code using System.Drawing; using System.Drawing.Imaging; namespace Utility { public class GifImageUtils { public static void SaveAnimatedGifFrames(string path, string outDir) { var gifImg = Image.FromFile(path); var dimension = new FrameDimension(gifImg.FrameDimensionsList[0]); int frameCount = gifImg.GetFrameCount(dimension); for (int i = 0; i < frameCount; i++) { gifImg.SelectActiveFrame(dimension, i); // create a frame image from the original source image - clone is mandatory var frame = (Image)gifImg.Clone(); frame.Save(outDir+"/"+i+".gif", ImageFormat.Gif); } } } } Exa

Java: Extract Gif Images From an Animated Gif Image

In this post, I will show you the code for extracting gif frame images from an animated gif image. I will show you two types of code: Simply extracting gif images stored in the original animated gif image Creating gif image by rendering and accumulating each gif frames stored in the original gif image Code for Extracting Gif Image From An Animated Gif Java Code package com.dukesoftware.utils.image; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import javax.imageio.ImageIO; import javax.imageio.ImageReader; import javax.imageio.stream.ImageInputStream; public class GifImageUtils { public static void main(String[] args) throws IOException { String sourceGif = "c:/temp/SmallFullColourGIF.gif"; saveAnimatedGifFramePartsToImage(sourceGif, "c:/temp/gif_parts"); } public static void saveAnimatedGifFramePartsToImage(String input, String outDir) throws IOException { ImageReade