Tag Archives: image

gif-to-ogv.sh: All GIFs must die

I’ve taken the giant leap forward in recent months, to the realization that All GIFs Are Evil, and it’s time to abandon that format. They’re heavy, slow, poor quality and just a drudge from a world of 20 years ago. And they tie up my meager Internet connection.

Of course, I say that knowing full well that a tenth of the images I’ve hosted here are cobbled together PNG files made into rudimentary GIFs. I’m working on changing that to something that will embed in WordPress.com’s atrocious post markup, but not require me to link to YouTube or beyond.

All of that aside, here’s one way to exterminate those cretinous GIFs: gif-to-ogv.sh. And of course, I have nothing to show for it, unless I post a before-GIF and an after-OGV. And chances are, they’d look remarkably the same to you. Which they should, if gif-to-ogv.sh was actually doing its job.

And my preliminary attempts seem to confirm it. You can adjust the quality or speed settings in the script, but for what I’ve seen it doesn’t accept any flags. Which is probably as well, since mplayer is involved, and mplayer has more choices than some ice cream shops.

avconv is also involved, and I mention that because avconv is something that appears in Debian-based distros, probably under libav-tools. If there is an Arch package that contains something called “avconv,” neither me nor yaourt nor pkgfile could find it. I’m sure it’s out there though. 😐

I don’t know what else to tell you about gif-to-ogv.sh. I seem to have a fair number of script-gimmicks in my list though, so perhaps these quick-fix tools will become a regular addition to applications. Then again, what’s the difference? 😉

aview: Let me draw you a picture

Thinking back, I haven’t seen a whole lot of ASCII art viewers for the console, with the exception of the ones that come bundled with the aa or caca libraries.

aview can do this though, and has enough side options to keep you pressing keys at random, hoping for a suprise mode.


I will tell you up front that aview wants its target file to be converted to PNM format, so you might want to dredge up imagemagick before you start in with aview.

Once it’s running though, you have quite a few nifty tricks at your disposal. aview is prepared to handle image inversions, several different types of dithering, zoom and un-zoom modes, frame-by-frame panning across images, and a lot more.

And I wasn’t joking about hitting keys at random: aview’s home page suggests there are some hidden features. If you find any, let me know. 😉

One nice touch about aview: You can save the resulting image into an HTML file, or your choice of about eight or nine other formats, replete with display, character and other options. How’s it look? Well, you be the judge.


Not gorgeous, but at least Tux isn’t embedded with evil hidden messages this time. 🙄 And that’s just the simplest of the available styles that I saw. Go crazy with that.

As a final note, I’ll mention that aview kicks into a graphical-ish mode if you trigger it from within a terminal emulator, which is why I demanded the curses driver in the gif above. It is smart enough to stick to text-only if you’re calling it from a virtual console though. (The caca suite was smart enough to do that too, if you remember that far back. cacaclock -f /usr/share/figlet/fonts/big.flf -d '%H:%M:%S' anyone? :mrgreen: )

And no, there’s no color, which I’m sure disappoints you as much as it does me. I will survive though, and I take some solace in noting that the last update to aview was more than a dozen years ago, if the home page is correct. I like software that can survive the times. 😉

wkhtmltopdf and wkhtmltoimage: The clever twins

I was very much torn on whether or not to include wkhtmltopdf and wkhtmltoimage here, or just throw them into the leftovers at the end of the W section.

As I understand it, these twins use WebKit to convert HTML documents into either PDF format, or to generate an image. It’s a nice idea, and works great.

kmandla@6m47421: ~/downloads$ wget https://inconsolation.wordpress.com
--2014-06-29 08:18:55--  https://inconsolation.wordpress.com/
Resolving inconsolation.wordpress.com (inconsolation.wordpress.com)...,,, ...
Connecting to inconsolation.wordpress.com (inconsolation.wordpress.com)||:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘index.html’

    [                                                                  ] 65,344       354KB/s   in 0.2s   

2014-06-29 08:18:56 (354 KB/s) - ‘index.html’ saved [65344]

kmandla@6m47421: ~/downloads$ wkhtmltopdf index.html index.html.pdf
libpng warning: iCCP: Not recognizing known sRGB profile that has been edited
Loading page (1/2)
Printing pages (2/2)                                               
Exit with code 1 due to network error: ProtocolInvalidOperationError

My hesitation comes in the fact that, as best I can tell, neither program can run without qtwebkit or X (although the Arch package page suggests Xvfb will work). So I’m fudging the definition of “text-based program” again, for a tool that doesn’t show much “text-based” to start with.

But this wouldn’t be the first time. We endured a barrage of pdf-conversion programs back in February, and some of those are no more graphical than these two. So I guess it’s okay.

What’s the output look like? Not bad at all.


PDFs are about the same quality, but of course split into pages and probably bigger.

Both wkhtmltopdf and its sister have an immense number of flags and options that allow an impressive level of control over how the pages are rendered and the quality you achieve. So don’t dismiss either as a fire-and-forget conversion tool; the opportunity is there to fine-tune the experience.

Just remember that you will more than likely incur the need for X if you want to try either one. :\

termrec, ttyrec, tty2gif and others: Pretty as a picture

I realize now, well after digging deep into the T section, that I should have broken apart a lot of the programs listed here and clumped them together in megaposts, like I did with 2048.c.

I’m going to do that again now with a series of applications that are intended to convert terminal output into a replayable format, and beyond. Knowing that, you might correctly infer that there’s not much to show. You would be correct. In other words, no screenshots. 😦

Recording what happens in the terminal is not new. If you remember script, the granddaddy of terminal recorders, you’ll know that this idea has been around for decades, and there’s nothing new in piping the output of your terminal screen (emulated or not) into a recorded session. The novelty comes in the variety of tools that will do it for you.

I intentionally skipped over one of these programs — termrec — a week or two ago. I’ll take care of that one today, and I also have nh_recorder, ttyrec, ttygif and tty2gif, plus a bonus at the end and an online solution to mention. For each one I’ll try to give a quick rundown on the high points and low points, and my overall impression.

Let’s go.


Pros: Very light, very transparent. Could be good for extreme cases where nothing else seems to function, or over specific network connections. Cons: Only dumps to a file; needs its counterpart, nh_player, to replay. No practical control outside editing the code. Seems to only update a line at a time. I.e, no real animation effects, only periodic line-by-line refreshes.

Overall: This might be just a primitive tool intended for use with old versions of NetHack. It works, even if it’s not really practical.


Pros: Supports remote sessions. Can start an application directly, instead of spawning a subshell (a la script). Can append existing recordings. Has playback and timer tools. Cons: Clips the terminal size, which means you may end up with large empty areas if you record ncurses applications. Only sends output to its own format. No compression options.

Overall: This is a step up from nh_recorder, but it’s frightening that it slices away at the terminal area and leaves large black swaths where your application should be. I hope that was something I did wrong. Regardless, it lacks some of the features that the upcoming applications have.


Pros: Converts ttyrec format files into animated gifs, by playing back ttyrec files and using imagemagick‘s import command on them. Cons: Somewhat haphazard in its delivery. Two-step process; ttygif makes a slew of specifically named images, then relies on an included shell script to concatenate them. Final product should be a recording of the terminal session, in gif format. Relies on imagemagick.

Overall: Just too spattered for my liking. Even short recordings create a mess in your directory. The only time I can see where this would be a good approach is if I needed to edit out specific frames of a recording, and even then it would be a chore. Conceivably this could allow some control over frame quality and delay though.


Pros: Automatic compression. Support for ncurses applications. Compatible with ttyrec. Option to append recordings. Will save in several formats. Can jump straight into an application, instead of spawning an additonal shell. Cons: Some screen corruption in playback of ncurses applications. Terminal size clipped. No automatic conversion to gifs.

Overall: This is step up from ttyrec, but it still seems to suffer the two main faults of its predecessor: I’ve seen a lot of corrupted playback, especially with full-screen console applications. And clipping the available recording area makes it only marginally useful to me.


Pros: One tool for the entire process — record, save, and convert. Control over filenames in both the saving and conversion process. Can replay its own binary save files. Automatic conversion to gif, if desired. Cons: Sometimes tricky to play back a file without overwriting it. Relies on imagemagick. No automatic compression. No control over image format, or flags passed to imagemagick. Can eat memory like a pig — I’ve seen it gobble a gigabyte for a 20-second 80×24 recording. Sometimes corrupts the output image, but only very rarely.

Overall: This is the one I use, mostly because it will record the entire terminal area, and generally it doesn’t garble the end result. I have accidentally overwritten a recording while trying to play it back, but the conversion to gif is convenient and thus far without fault (the one time it did create gobbledygook was probably my error). With a few small improvements, this could be the clear winner. If it doesn’t get a handle on memory consumption, it’s not going anywhere though.

The gifs you’ve seen over the past week or so were made with tty2gif, and I’ve more or less implanted it into my system after tinkering with the other four. It’s possible that there are others, but between script and these others, you should be able to find one you prefer.

Now a bonus goodie: termcast

termcast lets you broadcast terminal sessions live, a la twitch.tv or some other streaming video sites. I can’t say that I built up an entire system to show my own terminal sessions — the tools are there for that — but I did watch a game or two of nethack that someone else was playing.

termcast relies on ttyrec for broadcast, but you can watch a game with only telnet. I’m not sure if the same issues with corruption or terminal size persist through termcast. I know I did see some garble in the games I watched, but I assumed that was from differences in terminal environments or something related to telnet.

And as promised, an online solution: showterm.io

I got a link a long time ago to showterm.io but forgot what the name was, making it rather tricky to hunt down. James T. sent me a working link a few weeks ago, so I’ll credit him with the catch.

The showterm client installs through gem or by straightaway downloading the binary from the home page. Recording and uploading a session provides you with a link, which you can use to view the session or share with others.

If I remember correctly, I was able to upload a recording from an X-less machine, but it probably goes without saying that you’ll need some sort of graphical environment to view the link. I tried this quite a while ago, but I seem to remember elinks throwing its hands up in frustration when I fed it the showterm.io page.

I think that’s all for now. Taking these six or seven applications and loading them all on one post has taken a nice chunk out of my list, especially since there’s nothing in particular I can show for them, one by one. 😉

steghide: Naughty, naughty

Things like steghide make me wonder exactly how much trouble I could stir up, given adequate time of course.

steghide is that tool you’ve known existed for a long time, but didn’t want to ask about. Put simply, steghide embeds encrypted files within others — possibly images or sound files.

I haven’t tried every variation, mostly because seeing steghide work once was enough to convince me that I can metaphorically stash it in my pocket, and save it for a time when I really need it.

Here’s what it looks like. Ladies and gentlemen, I give you … Tux.


You may recognize Tux from films and movies. And now, Tux’s doppleganger, his evil Captain Kirk:


You wouldn’t know it to look at him, but the Evil Tux is hiding a dark secret. We should suspect that just by looking at the file size.

kmandla@6m47421: ~/downloads$ ls -sh
 40K 2014-05-10-6m47421-steghide-tux-original.jpg
 48K 2014-05-10-6m47421-steghide-tux-embedded.jpg

There’s something … odd about Evil Tux. Check with steghide, and it will confirm it for us.

kmandla@6m47421: ~/downloads$ steghide info 2014-05-10-6m47421-steghide-tux-embedded.jpg 
  format: jpeg
  capacity: 1.9 KB
Try to get information about embedded data ? (y/n)

Naughty, naughty. What’s this you’re carrying, Evil Tux? And more importantly, where have you hidden it? 😯

Try to get information about embedded data ? (y/n) y
Enter passphrase: 
  embedded file "secret.txt":
    size: 70.0 Byte
    encrypted: rijndael-128, cbc
    compressed: yes

steghide can yank that out of there in a jiffy. Just:

kmandla@6m47421: ~/downloads$ steghide extract -sf 2014-05-10-6m47421-steghide-tux-embedded.jpg 
Enter passphrase: 
wrote extracted data to "secret.txt".

kmandla@6m47421: ~/downloads$ cat secret.txt
Now is the time for all good men to come to the aid of their country.

Well that was anticlimactic. 😐 You can try it for yourself if you like. The password is 12345.

steghide has a lot options, and what you see above was just blatantly stolen from the quickstart guide. I imagine just about any file could be embedded into any other; like I said though, I didn’t try every variation.

Don’t get yourself into trouble, now. 😈

mplayer: At the framebuffer, or without

I’m jumping out of order slightly, but only for a day. mplayer is next, and I promised it to you a few weeks ago, when I mentioned mencoder.

I’ll keep this short. I’d hate to lump mplayer in with every other text application, because it’s an apples-and-oranges comparison.

Yes, technically it will run without X, and it sends a good deal of its status information to plain text. It will throw a movie up against the framebuffer, and it’s a clever trick.

It will also pipe images through the aa and caca video output, meaning you can actually watch a movie in textmode, albeit with a little loss of detail.

I’d hoped to show that here but fbgrab can’t really keep up, and the results are scrambled — very scrambled.

So you’ll have to take my word for it. Of course, it’s probably something you’ve seen done before. If you haven’t done it yourself.

I think that’s all I should say about mplayer right now. Configuring it and using it are two twin arts in their own right, for as complex and powerful a program as it is.

My advice is to seek out a mid-range laptop with some graphical oomph, and see if you can send a low-res, easily encoded file through to the framebuffer. If it works, great. If not … well, maybe next time.

It’s definitely worth trying though. 😉

libjpeg-progs: A quick flashback to the L’s

I promised a week or two ago that I had two leftover programs in the L section that I couldn’t investigate, because of technical issues at the time.

Here’s one of those two: libjpeg-progs. And while this isn’t really a singular program to itself, it does include a lot of goodies. Including:

  • cjpeg, to compress another format into jpg,
  • djpeg, to reverse that operation,
  • rdjpgcom and wrjpgcom, for reading and writing jpg comments,

and some other tools aimed at exif data.


Nothing flashy to show at the terminal, that’s for sure. The others are no more chatty either.

I’m using the name libjpeg-progs as the title here because that’s where they’re found in Debian; in Arch it looks like libjpeg-turbo, although I’m not sure offhand what the distinction is.

One more for the L section, just to be fair. Then more M programs. …

inkscape: Yes, this too has a text-only mode

The second post for today is a bit of a thumbsucker. Yes, it’s true, Inkscape can handle some operations without a graphical component.


I know I shouldn’t be any less enthusiastic about Inkscape’s non-graphical abilities than I should about imagemagick‘s vast repository of non-graphical abilities.

I guess my loyalties lie with the software that’s intended to work without X, et al., as opposed to software that offers command-line functions as a matter of course.

So yes, while the Gimp and avidemux and handbrake and a bunch of other tools can, technically work without a visual element, I get the distinct sensation that they do so under duress. 😐

Let’s move on. …

imagemagick: Graphics, ungraphically

I am sitting and staring at the screen now, unsure really what I could say about imagemagick that would astound or inspire.

I have a feeling that most people have heard of imagemagick, even if they don’t ever use it.

I for one use almost daily, in particular when I convert the framebuffer images to animated gifs that I use (sometimes) for these pages.

That’s only one small slice of what imagemagick can do though. If you really want to expand your horizons, here’s the man page for convert, which is only one of about 10 tools that come in the imagemagick bundle.

For most people, a command-line-based image editing tool is counterintuitive. After all, what good does it do you to edit an image if you can’t see it?

And there’s some truth to that. If I have one image that needs adjusting and I can’t be sure exactly where the cropping needs to happen, the Gimp is probably a better tool.

But imagine I have a hundred, or a thousand images that all need the same crop, at the same location to the same dimensions.

You could tinker with batch mode in Gimp, or you could just loop them all through imagemagick, and then go back to playing Minetest.

And for some, the beauty of imagemagick is that it doesn’t need a graphical component. Imagine a server that accepts images, then resizes them to fit certain dimensions. Again, no need for the intern to run each one through the Gimp, for hours every day.

There’s a tool for every job, and sometimes the best tool doesn’t need a visual interface. But that’s what I’ve been saying for years. … 🙄

gifsicle: Cool stuff I can’t show

gifsicle is that fun toy that everybody has, but nobody thinks to use. gifsicle slices and dices gifs. It boils them, mashes them, sticks them in a stew. If gifsicle were a hammer, every gif would look like a nail.

The sad part is, there’s not much for me to show. I can try:


But the things gifsicle does don’t really show up outside a graphical environment. I don’t believe fbi (of fbida) will show gif animation, so most of the things I would show would be static.

No matter. You can trust me. I’m on the Internet. 🙄

gifsicle can explode gifs into individual frames. It can rename those as you like. It can rotate, flip, crop, expand, add transparency, subtract transparency, insert frames, delete frames, add frames, add color, optimize, unoptimize, name frames and add comments. You name it, it does it.

And unfortunately, most of that I can’t really show.

So you’ll have to try it yourself. And remember gifsicle next time you go dashing off to some random Internet site, to break apart the frames of a gif of a cat playing a piano. 😕