Compositing Text Over Images

8 Inch USB Screen With Composited Text

I have a number of small USB-powered screens scattered across the apartment that displays various stuff that I find myself wanting to know.  In particular, I always want to know what music is playing. And I sometimes want to know what temperature it is outside.  (And I can tap the screens to pause the music.)

So I want to display the sleeve of the currently playing album, and I want to display the group/album/track name.  And on the screen in the “office”, I want to display the temperature in the room and the temperature outside.  Because I want to know how many layers of wool I have to put on before going outside.

“This should be easy enough to script up with ImageMagick”, you’re probably thinking.  But I want the font be Futura, and I want the text to have a “shadow” around it so that it can be read no matter what the background (i.e. the sleeve) looks like.

My go-to tool for all text-based things is LaTeX.  (Yes, I know.)  And after fiddling around a bit with LaTex and netpbm, I got the look I wanted.  (“A bit” is a euphemism for “a few minutes every day for a couple of weeks until it didn’t look hideous”.  (And “a few” is a euphemism for “a lot of”.))

This Is A Button

The solution I settled on was to take the output from LaTeX, convert it into pnm, and then blur the outlines for a number of times.  Then I used this blurred image as the alpha channel on a black image.  By then compositing all these images over each other (the background image first, then the black image with the alpha channel giving the outlines of the text, and then the text itself on the top), I got the result you can see on the image at the top.

Probably not usable for anybody else as is, but I’ve put the scripts up on GitHub anyway.  Somebody out there may want to do something similar some day, and perhaps this will help in some way.

And publishing code like this always helps.  It’s been through so many iterations that the code was just a total nightmare, and cleaning it up (as one does) before publication makes the code more maintainable for my personal use, too.

March 9th, 2012

Dear Diary,

I’ve switched the SSD disks back to the LSI MegaRAID SAS 9260-8i controller again, and did some final benchmarks.

I’m comparing reading bits of the Gmane spool in semi-random (i.e. ext4 directory) order, name order (which is also the same order as the files were created), and finally, just reading a big hunking file.  I’ve done this on a spinning disk, with soft RAID, and with the MegaRAID. The last two are over five Samsung 830 512GB in RAID5 mode.

  Semi-random order Name order Sequential reads
Spinning disk 234 files/s 2 MB/s 6062 files/s 48 MB/s 130 MB/s
Soft RAID5 over SSDs 4076 files/s 32 MB/s 8103 files/s 64 MB/s 264 MB/s
LSI MegaRAID SAS 9260-8i over SSDs 4564 files/s 36 MB/s 18708 files/s 148 MB/s 580 MB/s 

So, for the thing that matters — semi-random reads — we get a 20x improvement going from spinning magnetic disks to SSD.  However, the difference between using soft RAID over SATA2.0 versus using that spiffy MegaRAID SATA3.0 card isn’t very thrilling in my realistic use case.  

However, being able to read the 19K files per second when I’m doing, say, re-indexing or statistical analysis, will certainly be nice.  I’ll probably not get that speed when the machine is under load and serving out messages at the same time, but it’ll be a lot better than a contested spinning disk.

So to conclude:  The LSI MegaRAID 9260-8i was a waste of time and money.  I should just have soft RAID-ed the thing, as was my original plan.  But since I’ve got the card now, I might as well just use it.

I’ve now started the real syncing of the entire spool to the new machine.  That’ll probably take a few days, but I’m aiming for replacing the Gmane news server with the new machine sometime next week.  This will hopefully mean the end of all those “load over 16” login denials.

And, Diary, since it seems that some people are able to hack into you and read my most secret thoughts, I’m going to go back to writing you with a quill pen on parchment again.  Surely Google won’t be able to access you there.

March 7th, 2012

Brace yourselves.Winter is coming back

Dear Diary,

I’ve now found some time to do further speed testing of the SSD machine that’s going to replace the Gmane news server.  I know that you remember everything, Diary, but let me give you a brief recap.

I got a bunch of 512GB Samsung 830 SATA3 SSDs that are supposed to have IOPSes coming out of their ears. I got a RAID card, hooked it up, and was somewhat underwhelmed by the performance.  I got a read performance of 4400 files per second when reading in kinda-random order, despite the RAID card having SATA3 and a special “key” that was supposed to disable the built-in slowdowns. That’s ok, but not extremely impressive.

So today I hooked the SSDs up the the motherboard directly.  Unfortunately the motherboard only has SATA2, so the theoretical single-disk bandwidth is about 270MB/s.  Pitiful.

And, wouldn’t you know it, large-file performance towards a single disk was 250MB/s when writing, and 265MB/s when reading. For small files, I get 4000 files per seconds, and 32MB/s.

So pretty much as expected.

Then I created a soft RAID5 over the disks.  Large-file performance is 520MB/s, which is less than half of what I got on the SATA3 RAID card.  The small file performance is 4200 files per second, which is just vaguely south of what that supposedly spiffy RAID card gave me.

This is all rather disappointing.

Diary, I’ll try once more with the RAID card, mixing up the RAID parameters, but I have little hope that much will change.  I’ll have to settle for 4K/s performance when serving out messages from, I think.

Tentacle Mystery

I ordered…  something… as the appetizer at the restaurant tonight.  I’m pretty sure I didn’t expect this tentacle plate to appear, though.  Did I order it?  Was the waiter just having fun?

Anyway, what it is?  It kinda looks like octopus, but not quite.  The tentacles don’t quite look octopussey enough.  And the texture wasn’t squid-ish.  At first I thought it was mozarella.  Then I thought chicken.  Then I thought…  I don’t know.  Anemone?

It was delicious, though.  But mysterious.  Does anybody know what the tentacle platter might have been?

Baffled Pizza

Take your backpacks off!

There’s a pizzeria just down the street here that almost always has a long queue outside.  Pizzeria da Baffetto. Naturally, if there’s a long line, I want to be there, too.  Or perhaps not.  But I was thinking that that might be the reason that all these people were standing out in these rather cold Rome February evenings when there are oodles of perfectly fine pizza to be had virtually everywhere.

The self-perpetuating queue model.

Anyway, I Googled the place, and it’s apparently “the most reviewed restaurant in Italy”, according to my guide book.  It didn’t mention what the reviews actually say.

The second review on Google Reviews says I could find this place, and gives it one star.

More forthcoming are reviews like this:

Unacceptable behaviour. If you go there be prepared to very rude staff. It’s not about the typical roman style that makes many places so unusually attractive. No, they are just rude in a way that makes going there an annoying, embarassing experience.

So it’s not the typical Roman style of rudeness we all love (but I haven’t actually noticed), but a special form of unattractive rudeness.

The unique “no backpacks” sign shown in the picture above is apparently no joke, either:

Those with backpacks had them ripped off their backs

I think that’s an eminently sensible policy.  You shouldn’t wear backpacks indoors.  Or outdoors.

The American reviews are often unintentionally hilarious:

I’m from brooklyn so i didn’t have high expectations to begin with but this did not live up to the hype at all! the pizza! the pizza is very thin and the sauce does not compensate

I’m guessing this Brooklynite may also have been dismayed that he was expected to eat the pizza with a knife and fork.  It’s provincialism at its most amusing.

I still haven’t dared visit the place, though.  Too much drama.