2

In my project, i need to help people to reduce the size of image. I have created an image resize method which work well for almost image format but not animated GIF!!

Therefore, i want someone to help me to make it :)

I have designed the process of how to resize an animated GIF:

  1. get the image in byte data=>

  2. split the frame of GIF to Image array =>

  3. resize each Image of the array =>

  4. combine those images to one GIF image =>

  5. convert the GIF image to byte data =>

  6. upload the byte data to cloud

I am not asking what is the code to do this, but asking is it possible?

My design code:

static void Main(string[] args)
{
   Image gifimage = getImageFromByte();  //created
   Image[] images = GetFramesFromAnimatedGIF(gifimage); //creating
   for (int i=0; i< images.Length;i++)
   {
       images[i] = resize(img, size); //created
   }
   Image combinedImg = combineImgArrToImg(images); // not create yet
   byte[] imgData = convertImgToData(combinedImg); // created
   uploadImg(imgData);  //created
}

About the GetFramesFromAnimatedGIF method, it is:

 public static Image[] GetFramesFromAnimatedGIF(Image IMG)
 {
    List<Image> IMGs = new List<Image>();
    int Length = IMG.GetFrameCount(FrameDimension.Time);

    for (int i = 0; i < Length; i++)
    {
        IMG.SelectActiveFrame(FrameDimension.Time, i);
        IMGs.Add(new Bitmap(IMG));
    }

    return IMGs.ToArray();
}
Community
  • 1
  • 1
king yau
  • 500
  • 1
  • 9
  • 28
  • "Reduce the size of image". Does this involve the file size or the pixel dimensions? – Uwe Keim Sep 28 '16 at 08:35
  • @ reduce the width and height of the image – king yau Sep 28 '16 at 08:36
  • Possible duplicate of [How to resize an animated gif image using C#?](http://stackoverflow.com/questions/539034/how-to-resize-an-animated-gif-image-using-c) – Jakub Jankowski Sep 28 '16 at 08:40
  • @JakubJankowski not, i am asking that is my workflow possible. – king yau Sep 28 '16 at 08:45
  • Resizing is not difficult, trivially done with Graphics.DrawImage, it is saving the GIF file back that is the problem. .NET does not support saving animated GIFs, you'll have to go shopping for a library that can do it. – Hans Passant Sep 28 '16 at 11:36

0 Answers0