public static void Run() { //ExStart:ConvertGIFImageLayersToTIFF // The path to the documents directory. string dataDir = RunExamples.GetDataDir_ModifyingAndConvertingImages(); // Load a GIF image and Convert the image to GIF image Image objImage = Image.Load(dataDir + "asposelogo.gif"); using (GifImage gif = (GifImage)objImage) { // Iterate through arry of blocks in the GIF image for (int i = 0; i < gif.Blocks.Length; i++) { // Convert block to GifFrameBlock class instance GifFrameBlock gifBlock = gif.Blocks[i] as GifFrameBlock; // Check if gif block is then ignore it if (gifBlock == null) { continue; } // Create an instance of TIFF Option class and Save the GIFF block as TIFF image TiffOptions objTiff = new TiffOptions(TiffExpectedFormat.Default); gifBlock.Save(dataDir + "asposelogo" + i + "_out.tif", objTiff); } } //ExEnd:ConvertGIFImageLayersToTIFF }
public static void Run() { // To get proper output please apply a valid Aspose.Imaging License. You can purchase full license or get 30 day temporary license from http:// Www.aspose.com/purchase/default.aspx."); // ExStart:ConvertGIFImageLayersToTIFF // The path to the documents directory. string dataDir = RunExamples.GetDataDir_ModifyingAndConvertingImages(); // Load a GIF image Image objImage = Image.Load(dataDir + "asposelogo.gif"); // Convert the image to GIF image using (GifImage gif = (GifImage)objImage) { // iterate through arry of blocks in the GIF image for (int i = 0; i < gif.Blocks.Length; i++) { // convert block to GifFrameBlock class instance GifFrameBlock gifBlock = gif.Blocks[i] as GifFrameBlock; // Check if gif block is then ignore it if (gifBlock == null) { continue; } // Create an instance of TIFF Option class TiffOptions objTiff = new TiffOptions(TiffExpectedFormat.Default); // Save the GIFF block as TIFF image gifBlock.Save(dataDir + "asposelogo" + i + "_out.tif", objTiff); } } // ExEnd:ConvertGIFImageLayersToTIFF }
public static void Run() { Console.WriteLine("Running example ConvertGIFFImageFrame"); // The path to the documents directory. string dataDir = RunExamples.GetDataDir_WebPImages(); // Load GIFF image into the instance of image class. using (Image image = Image.Load(dataDir + "asposelogo.gif")) { // Create an instance of GIFF image class. GifImage gif = image as GifImage; if (gif == null) { return; } // Load an existing WebP image into the instance of WebPImage class. using (WebPImage webp = new WebPImage(image.Width, image.Height, null)) { // Loop through the GIFF frames for (int i = 0; i < gif.Blocks.Length; i++) { // Convert GIFF block to GIFF Frame GifFrameBlock gifBlock = gif.Blocks[i] as GifFrameBlock; if (gifBlock == null) { continue; } // Create an instance of WebP Frame instance by passing GIFF frame to class constructor. WebPFrameBlock block = new WebPFrameBlock(gifBlock) { Top = (short)gifBlock.Top, Left = (short)gifBlock.Left, Duration = (short)gifBlock.ControlBlock.DelayTime }; // Add WebP frame to WebP image block list webp.AddBlock(block); } // Set Properties of WebP image. webp.Options.AnimBackgroundColor = 0xff; // Black webp.Options.AnimLoopCount = 0; // Infinity webp.Options.Quality = 50; webp.Options.Lossless = false; // Save WebP image. webp.Save(dataDir + "ConvertGIFFImageFrame_out.webp"); } } Console.WriteLine("Finished example ConvertGIFFImageFrame"); }