Post navigation

Screen area to Animated GIF

Recently I’ve discovered that there is a plethora of platform-specific utilities that can repeatedly capture region of the screen and then save the resulting images as an animated GIF. To me this sounds like a perfect task for JVM, since JVM includes support for screen capturing and creating animated GIF images, and all this comes with cross-platformness.

Let’s start with the demo right away!
(UPD: see demo on Raspberry Pi at the end of the post)

Here is the GIF that shows the utility in action. This gif was produced by second instance of the utility capturing the screen part where the demoed instance was displayed. Nice, huh? I ran screen capturing while I ran screen capturing so I could capture screen while I capture screen (-;

The utility allows one to specify a capturing region by placing a special frame over the part of the screen to be captured. Note that when using Java 7 this frame will be translucent. In older versions of Java though it won’t be.

After one have chosen the proper location, he can snap one shot of it (this will automatically hide the region selection frame) or start a sequence of snapshots with specified interval between them (for this though one should manually hide selection frame by pressing corresponding button – otherwise it will appear on screenshots made).

The captured shots can be previewed, the unnecessary ones can be deleted (use delete or backspace button for that). Then user has the option to export them as animated GIF (with delay inbetween frames specified same way as delay inbetween capturing shots), optionally this GIF can be looped.

Also one can store individual shots in different formats.

Note that formats support depends on Image Writers supplied with JVM, so different JVMs can provide different set of formats. Possible one’s JVM may be actually unable to save GIFs (ouch), but I suppose this won’t happen on most of modern JVMs. UPD: I have successfully run the utility on JDK8 preview for Raspberry Pi (which is a cheap and rather weak ARM-based computer), only thing missing was opacity support! So it should work on really weak JVMs (-: