Esempio n. 1
0
    public static void ResizeAnimatedGif()
    {
      // Read from file
      using (MagickImageCollection collection = new MagickImageCollection(SampleFiles.SnakewareGif))
      {
        // This will remove the optimization and change the image to how it looks at that point
        // during the animation. More info here: http://www.imagemagick.org/Usage/anim_basics/#coalesce
        collection.Coalesce();

        // Resize each image in the collection to a width of 200. When zero is specified for the height
        // the height will be calculated with the aspect ratio.
        foreach (MagickImage image in collection)
        {
          image.Resize(200, 0);
        }

        // Save the result
        collection.Write(SampleFiles.OutputDirectory + "Snakeware.resized.gif");
      }
    }
 private static MagickImage ExecuteCoalesce(MagickImageCollection collection)
 {
   collection.Coalesce();
   return null;
 }
    public void Test_Coalesce()
    {
      using (MagickImageCollection collection = new MagickImageCollection())
      {
        ExceptionAssert.Throws<InvalidOperationException>(delegate ()
        {
          collection.Coalesce();
        });

        collection.Read(Files.RoseSparkleGIF);

        using (PixelCollection pixels = collection[1].GetPixels())
        {
          MagickColor color = pixels.GetPixel(53, 3).ToColor();
          Assert.AreEqual(0, color.A);
        }

        collection.Coalesce();

        using (PixelCollection pixels = collection[1].GetPixels())
        {
          MagickColor color = pixels.GetPixel(53, 3).ToColor();
          Assert.AreEqual(Quantum.Max, color.A);
        }
      }
    }
Esempio n. 4
0
 private static MagickImage ExecuteCoalesce(MagickImageCollection collection)
 {
     collection.Coalesce();
     return(null);
 }