Posts Tagged ‘gimp’

Batch-cropping screenshots

Tuesday, January 4th, 2011

Yesterday I set out to create a couple of screenshots I needed for an idea I’ve gotten. What I wanted to screenshot was vim.

For some reason or other, scrot -s followed by manually clicking on the window to screenshot didn’t work. The resulting screenshot just showed an empty terminal (or not even that, just the background (shining through the transparency of my terminal).

Screenshot:ing the entire screen produced the desired results, except for showing everything else on the screen.

First idea was to use GIMP and simply cut out and save the portion of image I wanted, and GIMP is great and all, and I could probably have automated it somehow, but truth be told, on the 10″ screen of my netbook, that was less than optimal.

Imagemagick does have several interesting features, among them cropping.

So this is what I ended up doing:

  1. Get the width and height of the portion of the screenshot I wanted to extract, using GIMP
  2. Get the (x, y) coordinate pair for the upper left corner of the portion of the screenshot I wanted to extract, again using GIMP
  3. Make backups of all the screenshots ( $ mkdir backup; cp *.png backup/ )
  4. Using a for-loop, calling on imagemagick to crop the screenshots, one file at a time
$ for f in `ls *.png`;
do
    convert -crop 511X293+513+0 "$f" "${f%.png}.cropped.png";
done

i.e crop a rectangle 511 pixels wide, 293 pixels high, whose upper left corner is at (513, 0).

The resulting filenames weren’t all that impressive (e.g. screenshot-1.png.crop.png) but it was a burden I was willing to bear, given how easy it would then be to rename them using mmv.

Just a small
$ mmv "screenshot-*.png.crop.png" "screenshot-#1.cropped.png"
and the “.png” in the middle was gone :)

(updated (2011-02-18 23:25) with great tips from Nicolas.)

My software stack revisited – (Multi)media and entertainment

Thursday, December 23rd, 2010

I am probably abusing the English language with this use of the word multimedia, but I just couldn’t find any better way of describing audio, video and images in a word… sorry :P

Video

For playback I mostly use mplayer, but for some reason or other, keep VLC around, although I can’t really explain why.

I’ve successfully used k9copy to make backups of my DVD-collection, works great :)

Audio

Ok, so you know I like living on the command line, right? So it won’t come as a surprise to you when I say that I used to use cplay? I still keep it around, it really is quite nifty, but the lack of an easy (and documented) way of interacting with it externally (say, through keyboard shortcuts) made me finally look elsewhere (having to jump to a tag in order to pause the music when the phone rings isn’t fun).

So when I discovered moc (Music On Console) I was pleased. I could script it to my heart’s delight. Even better: it doesn’t need its curses-based UI to function, so I only bring it up if I want to edit the playlist, hit q when I’m done, and kill the terminal, and the music keeps flowing.

And for converting videos or audio between formats (or extracting the audio from a video) ffmpeg is the tool to do the job.

For finer editing of audio files, I use Audacity.

Images

For image viewing, I use eog and geeqie, which does a good job of complementing each other.

And although not a regular activity of mine, for a small project I was doing in my spare time recently I got the chance to use both Gimp and Imagemagick.

I’ll see to it tonight that I’ve used Inkscape more than three times so that I can honestly put it on the list as well, it deserves to be there.

Entertainment

I find astronomy quite fascinating, and although that is on a very amateurish (to the point that I haven’t bought a telescope or anything yet) level, Stellarium is a superb software.

festival, a text-to-speech synthesiser, might not at first glance seem all that entertaining, but it can indeed be, not to mention I actually got use for the accompanying package text2wave when setting up notifications for my instant messenger (audible hints that specific people have come online).

No list outlining entertainment would be complete without a mention about games and since I do, from time to time, need to get my mind off things, games provide the perfect distraction.

The bsd-games package contains a couple of CLI apps, both semi-useful stuff, and some games. Wump is my favorite game from that package, mostly due to fond memories from ITU.

Games are otherwise still one of the big problems for GNU/Linux although indie-developers like the ones who come together in the Humble Indie Bundle, are making good progress in making gaming platform-independent.

Finally I find programming quite entertaining, but that will be the topic for the next post, so I’ll end things here.

:wq