0

I'm looking for a function that could process animated gif image to write text on top of it.

The working solution is probably provided by Gif4j lib, but I'm looking for open-source solution or advice how to implement it on my own.

How can I put text on a gif and save it as a new gif in Java?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Andrey Mormysh
  • 809
  • 5
  • 12
  • `Graphics.drawString()` but not sure if it would work for an animated image. – Nikolay Kuznetsov Dec 14 '12 at 00:54
  • 1
    [This](http://www.javakb.com/Uwe/Forum.aspx/java-programmer/32892/Help-with-GIF-writer-in-imageio#art5) is creating an animated gif using ImageIO. You could just draw the text on the offscreen images before you create the gif – Clark Dec 14 '12 at 01:14

1 Answers1

3

You need to:

  1. Split the animation into separate frames.
  2. Write the text on each frame. For examples see answers like these (the first is more closely related, but the second source does the same, and is simpler).
  3. Construct the frames into a new animated GIF. See Create animated GIF using imageio at the OTN, where I discuss the code used in a GIF animation tool.

Community
  • 1
  • 1
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433