meme x giffy

The other week I was tinkering with editing GIF animations in Emacs, and then I started wondering: Can this be any more ridiculous?

Yes.

So it’s a mashup of the Emacs meme mode and the new GIF animation code.  I spent most of the time on this wondering whether I could somehow make one or the other a minor mode before giving up and just mashed the code into meme.el, which can be found on Github.

The main challenge here was figuring out how to make this fast enough.  The first naive implementation just created an SVG 25 times a second with all the data in it, and Emacs just isn’t fast enough to print a ~2MB XML structure that often.  (Not to mention when animating bluray screen grabs: The SVG structure is then about 7MB.)

So I cheated and pre-computed the screengrab bits, and then plonked down those bits into the printed XML structure.  Which made it fast enough even for bluray animations on my rather spiffy machine; your mileage may vary.  If your machine is too slow, you may have to pre-downscale the screengrabs the animations are based on.

Exporting to GIF and MP4 is supported if you have ImageMagick “convert” and “ffpmeg” installed.

 

Of course you should be able to make animated GIFs in Emacs

I was wondering what a convenient production process for GIFs from movies would be like, so I hacked my hacked version of mplayer a bit more.  Nothing major, since it already has all the functionality, but it doesn’t group continuous screenshots by name, which makes picking out the animations afterwards awkward.

There’s probably a gazillion GIF editors out there already, but since the things you typically want to do with an animation (trim start/end, adjust speed and how many frames to skip) are kinda trivial, it seemed more convenient to just write a mode in Emacs.  So I did.

It uses the ImageMagick “convert” command to actually stitch the images together in the end after you’ve done the edit, so it’s not a pure Emacs-only solution.

And here’s the result:

I’m sure this is going to turn out to be really useful some day!

Editing Movie Posters From Emacs

I was waiting for some people to drop by yesterday to pick up a sofa, and I started thinking about how nice it would be to pull down movie posters automatically and perhaps put some text or border or something on them.

Instead of sensibly looking for an API for this kind of stuff, I wondered whether I could just quickly alter the imbd.el library, since it already had some imdb parsing functionality, and I have all films tagged with imdb IDs.

The short answer is “no, that can’t be done without insane hacks”, and the longer answer is, “I did it anyway”.

The imdb website uses a Javascript thing to display a “carousel” of images, and parsing Javascript with regexps and stuff isn’t something that can be recommended.

But it works right now, and will probably break when imdb does the smallest possible change to their code, but hey, whatevs.

To alter the images (as an example, I’ve added that red border with the wrong date up there). I wrote a teensy little library that just creates an SVG image, plonks the poster JPG into the SVG and then adds the border and text.  Composing images like this via SVG in Emacs is incredibly easy, especially since you can “live edit” the images by altering the SVG programmatically.

And then the couch people finally arrived.

Emacs Non-Flickering Patch

Earlier today, Daniel Colascione merged his double-buffering Emacs display patch, and I was interested in seeing whether it reduced flickering when viewing animated GIFs on my problematic main machine.

And it sure does:

First you see an Emacs from five hours ago displaying a GIF, and it is flicker-o-rama.  Then I switch to a brand new Emacs with Daniel’s patch, and it is completely flicker-free.

Now, that the flicker was there in the first place is probably due to me not bothering to figure out what settings the Nvidia driver needs to … work better: On my laptop, there was no flickering even without Daniel’s fix.  So your mileage will vary, but it’s obviosly a major step forward, flicker wise, on some machines.  Thanks, Daniel.

Emacs Imgur Interface

It was suggested on github that the Emacs meme creator should offer uploading images to imgur (and return the resulting URL) for max magic.  That seems extremely true.

There is already an imgur.el on github, but it’s doesn’t seem ideal (it does much more than just uploading; it seems to be using an older API; it relies on external programs; and most seriously: it wasn’t written by me), so I wrote a new one.

(For convenience, I’ve included the imgur.el in the meme repository, too.)

Kudos to the imgur people for creating such an easy API for uploading images.  It literally took 15 minutes to write imgur.el.  Literally!

powerful

An Emacs Meme Generator

I got an idea tonight: Emacs must have a meme generator.  Using a web browser seems so jejune.

After pondering a few minutes and then typing a few hours, here it is.  And here’s how it looks in action:

It basically just manipulates an SVG image, so it’s less work than you’d expect.

If you want to play around with it, you need a very fresh Emacs trunk; see this for easy installation instructions.  You also need the Impact font from the Microsoft font collection; in Debian it’s installed by saying

apt-get install ttf-mscorefonts-installer

Uhm…  I think that’s basically it.

useful