Flashair, Emacs and Me

My blogging methodology is that I 1) open an Emacs Message buffer, write stuff, and then 2) take pictures of stuff (mostly comics), wanting to have those images appear right where I’m typing. This is a solved issued with Flashair, PyFlashAero and watch-directory.el, but I thought that it sucked that there were so many moving parts.

And besides, PyFlashAero didn’t always do the right thing, and you have to specify so much stuff…

So I wanted to bring it all into Emacs for less fuss. You know this makes sense.

I had a third generation Toshiba Flashair card (W-03), and the problem is that it’s just too slow for my approach, which is basically to look into all directories on the card. It’s s-l-o-w. So I gave up in the project. PyFlashAero was written that way for a reason.

Half a year passed, and then I somehow was made aware that Toshiba had launched a new generation of their product, and it promised 3x faster WIFI speeds and a brand new and faster CPU.

So I got a card:

And I would like to say that it was an immediate success, but it definitely wasn’t. I could download the directory indices nice and fast, but whenever I tried to download an image, it stopped after 0 (zero) bytes. So it seemed like that card had a problem reading itself, basically, and would just hang whenever I tried requesting some data from the (exfat) file system on the card.

But! There was a new firmware W4.00.02, and I had W4.00.00. I installed the new firmware, and presto! It is teh work!

Look, I can snap pics of myself here I’m typing this stuff on the couch:

And it appears in the buffer within a second or two after I snap it! It’s a new paradigm! And it’s untouched by filthy unclean Pythonic hands; it’s all pure Emacs.

The range of the Flashair W-04 also seems improved… the old one had to be within a few meters of my laptop for the laptop and the Flashair to be able to communicate whereas the W-04 seems to be able to communicate over, er, more meters. Here, I went out into the hall and snapped a pic and this image was here in this buffer when I got back:

It’s magic!

But when I went to the kitchen and snapped a pic there, nothing showed up here, so it’s not that magical.

Anyway, here’s the Emacs source code.  You probably need a newish Emacs version for it to work.

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