Getting the first frame of a GIF image without downloading all the other frames

前端 未结 1 1530
花落未央
花落未央 2021-02-14 09:17

I would like to get a GIF image from the network, but I found that if I download the whole GIF image, it would cause a lot of network traffic.

Can I get only the first f

1条回答
  •  感情败类
    2021-02-14 10:01

    Well, I haven't found ready-to-use solution, but you can do this way (it'll lead to some "low-level" tricks):

    Following wiki about GIFs, animated gif files can be splitted into frames, and end of frame can be easily recognized. So, you'll need to read GIF header, screen information, information about animation into buffer, download first frame and append information like GIF is ended ("3B" following wiki article). And, if you copy this data into separate bufer, you'll be able to continue whole file downloading without re-downloading first frame.

    Also you can edit header information to format first frame into static gif.

    0 讨论(0)
提交回复
热议问题