from gimpfu import *
def process (file):
img=pdb.file_xpm_load("/home/enrico/tmp/cazzeggio/"+file+".xpm", file+".xpm")
pdb.file_png_save_defaults(img, img.active_layer, "/home/enrico/tmp/cazzeggio/"+file+".png", file+".png")
# (update) added to dispose of the image to avoid gimp swap to grow
pdb.gimp_image_delete(img)
for i in range(1, 10000):
process("img_%05d"%i)
Tested in the gimp python-fu console, it works, with the save and load progress
bar popping up all the time grabbing the focus from whatever I was doing.
There is a run_mode that can be passed to those file_xpm_load and
file_png_save_defaults, however python-fu is happy to let me know that I don't
need to bother about it. I searched, searched searched and I found out that
this really means that there's no findable way to tell Gimp functions to STFU
with python-fu.
Now, how do I run that script AND be still able to use my computer?
gimp has a nice --batch commandline option, from which it seems to only
understand scheme. It has a --batch-interpreter option, but I couldn't find
out any possible value that could make --batch understand python.
So, it seems that the only way to run python is to either register a plugin, or
type it in the python console. And no STFU.
So I tried Xnest, so that I could at least iconise the whole thing out of my
way. But it seems that xnest is denying connection from all clients I try to
run in it.
So I've run a VNC server. In the VNC server I run Gimp. Then I fire up the
Python console inside that Gimp. Then I paste the script in the Python
console. Then it starts working and I close the VNC client to get rid of the
popups.
Finally, this script helps me delete the big XPM files after they've been
converted to PNG:
#!/bin/sh
for i in *.xpm
do
if [ -e basename $i .xpm .png ]
then
echo rm $i
rm $i
fi
done
If there were easier ways to do what I did, please mail me and I'll document
them: no matter how I searched, I couldn't find any.
Update: it seems that in the Gimp python script, the image doesn't get
automatically garbage collected. As a result, the file
~/.gimp-2.2/gimpswap.whatever keeps inflating, so space is not really saved by
converting the XPM files to PNG, unless I restart Gimp from time to time.
Update: I found a function to deallocate the image: maybe that avoids the
growth of the Gimp swap.
#!/usr/bin/env ruby lines = [] while line = gets() do lines << line end while ! lines.empty? do idx = rand(lines.length) puts lines[idx] lines.delete_at(idx) end(Any Ruby afficionados out there, feel free to e-mail me and tell me what egregious sins I've committed). I think it looks reasonably neat and clean, it's certainly simple, and the use of real Object Orientation makes for a certain readability (I think the method call lines.empty? is particularly cute, although I did initially consider the use of a question mark in a method name to be a crime against humanity). So, will I be using Ruby more in the future? I think so. There are some features in Ruby which I'm hoping to get a lot more cosy with -- the idea of "blocks" looks particularly interesting, and I don't think the utility of languages that have been designed, top-to-bottom, to really live the OO ideal has been explored enough (you SmallTalk bigots can stop glaring at me now -- really, I mean it -- stop it!). It's far too early to tell whether Ruby will become my "go to" language for random development tasks, but anything that stops the nightmares (where I start thinking about using PHP as a general scripting language) cannot be all bad. And, if I continue to make new webapps, Rails will probably come in handy. Update: HTML <pre> tags don't like having < inside them unescaped. Also, Philipp Kern pointed out that the Ruby documentation browser is called ri (not ir as I originally wrote). Philipp was also kind enough to provide a much shorter version of my original script, which shows the power of Ruby so much better:
lines = [] STDIN.each_line line lines << line lines.sort_by rand .each line puts lineNow tell me that isn't a language worth using!

A last view over Manhattan
Mako was developing a plan in secret, though, which involved micah and his
car. Micah found out soon after. We went back to Clint's, expecting to find
sladen somewhere, but we didn't. I packed my things, and when we really needed
to go, we resolved to put his things in the entrance so he could find then and
do whatever he wanted on his return.
We went on the Metro to Union Square, where, hear this helix, I saw TONS of
raperos doing their break-dance thing (ok, maybe not tons, but I did see them).
And two blocks away, we arrived to the most incredible book store.
Mako has blogged many times about buying very rare books at the Strand for
ridiculous prices, but this was totally unexpected. The Strand is
huge. On the outside, there's carts with hundreds of second-hand
books, all for one dollar. Mako used to go there and browse the books to find
interesting stuff. The Acetarium is full of them! Most of the dollar books are
total crap though. A very high percent talk about god, religion, "our troops"
and stuff like that. Mentally filtering what might be good and what is not is
not easy when you haven't done it before.
Mako started scanning the shelves as soon as we arrived, and every now and
them he'd pick some totally stupid title. I was on my own shelf, missing many
good stuff, while mika, Clint and mako did their own. Clint found quite a few
titles, but mako didn't find anything good. I got lucky though, and found the
precious book of the day: The Spanish Anarchists. The heroic years
1868-1936, by Murray Bookchin. Although old, it was in very good condition,
and mako immediately asked if I was taking it. :) I won!
The inside of the Strand was incredible too. Three very big floors packed
with books, plus the half-priced "reviewer's copies" at the basement. I was
totally overwhelmed by the amount of books I'd be interested in buying, and the
limited weigh I should be carrying back, so I did my best not to look too
carefully.
For a few hours, I didn't have a too clear idea of what mako's plans were.
At some point, micah phoned him and we rushed to the PATH, the train that goes
to New Jersey. Apparently we were meeting micah at Newark, but I still didn't
know why we had to go there. During our ride, I could see how pleasant New
Jersey is to the human eye. Miles and miles of heavy industries. I'm pretty
sure it's the ugliest place I've ever seen. What I couldn't see, and I'm still
disappointed, is any of the viciously arrogant rats of the New York metro
system. Mako had told me about how they look at you, like saying "if you come
down here, you'll be left with 9 fingers", and the incredible number of them on
the tracks. Unfortunately I couldn't see any. I blame Michael Bloomberg.
At Newark, micah appeared in his car, and we all hopped into it. We
apparently were going by car to Boston... including Clint. I was puzzled, as he
had to work on Monday, but he'd said that he'd simply "come back". There was a
problem though, mako had dilinger's keys, and he was going back to NYC from
Boston, and we didn't have time to get to Boston before he left, so we had to
find a way of leaving the keys in NYC so he could get into his appartment.
Finally, mako resolved that Clint would be left in a cold street, in a rough
area of NYC, and he would handle the keys problem. I still didn't understand
what was going on.
We headed North, and I quickly fell asleep on mika's nap. I'm getting old.
When the car stopped again and I suddenly woke up, I looked ahead and...
HORROR! We were at the door of a McDonads. WTF WAS GOING ON? So it seems that
when you're on the road, there's no much other choice than shit food. After a
quick discussion with mako about how badly those burgers taste, I quickly went
back to sleep, until we were in Boston. It took a while to find a parking spot,
because all of them "permit only". It's impossible to park if you come from
somewhere else.
I was finally at the Acetarium, a
very cool flat in Cambridge, 15 minutes away from the MIT. It was 3:30 in the morning.
The day after, we woke up pretty late, and as I opened my laptop and found a
privmsg from sladen, he was was knocking at the door. This man has an
incredible ability to disappear and reappear when he's most unexpected.
Apparently he managed to grab his stuff in NYC, fetch the bus and arrive at 2
in Boston, meeting dilinger at the station, and mako as he went out to MIT.
micah and I went to explore Boston, but never managed. We consumed a few
hours when trying to ship some equipment to micah's colo, and then trying to
find food. When we were ready to go, micah got a very badly timed call, which
made him go back to the Acetarium: a server at work was dying or dead. At one
point, it was late enough that going to Boston wasn't worth it, so we went to
visit the Media Lab instead.
On our way there, micah and I kept chatting about this and that, and found
out how small the internet is. We both know a bunch of common people from
uncommon places like Per , from our involvement in social projects in the net
like Indymedia and Sindominio.net.
The MIT is incredible, specially the Stata Center by Frank Gehry. We
wandered around as we only got voice mail from mako, until an hour later we
found we was like 20 metres away from us. He gave us a tour through the Media
lab, and it was incredible. I had never seen something like that. Every lab was
colourful and fun, and very cool developments were going on everywhere. I also
saw the coolest mame box ever, with an arcade case and everything.

The Stata Center, right next to the Media Lab
After the tour, micah and I headed back, while sladen stayed to have a look
at one of mako's projects. When we got back to the flat, there were a few
people already there for mika's sushi party, and I rolled my first sushi rolls,
which was fun. A bunch of Debian people joined us, including zufus and gravity,
and had a great chat with them. The party ended way too late and after too many
beers.
sladen used his secret disappearing abilities, and a few colleagues from
mako crashed, so there was a bit of overbooking. Mako's solution was simple.
mika, him and I could share their bed.
I can't say I have slept too much, because mako would keep pulling the
blanket and leave me out in the cold, and I was trying not to squish mika. But
it went ok, although we discovered too late that mika was hot while I was cold,
and we swapped our places too late.
Today, we'll go find the Freedom Trail and walk a bit around it, meet
gravity and zufus for lunch, and I will sadly have to go back to Cambridge,
quickly pack and head to the airport to catch my plane. My hours in North
America are expiring.
Sony claims that it needs to install dangerous, malicious, underhanded software on its customers' computers to protect its copyrights, but in order to write this malware, it has no compunction about infringing on the copyrights of public-spirited software authors who make their works available under free software licenses like the GPL. I suppose it's natural to believe that everyone is at least as sleazy as you are: for Sony's rip-off artists, assuming that paying customers are planning to rip them off must come easy.How can anyone even vaguely involved in the tech industry possibly believe that anything they write can't be popped open and peeked in, to find out what naughtyness they've done? The mind boggles. Sony, you are on my official shit list. It's a long and prestigious list, but you've managed to climb very quickly to the upper echelons. May the fleas of a thousand camels infest the nether regions of every Sony executive who may have had anything to do with this whole fiasco. The original article is available, and is quite informative. Yay for BoingBoing, also, who provide me with so much of my daily interesting news.
In no case should you be doing complex programming in a shell script!
Learning the POSIX standard shell is time well spent, IMO. Most shells implement it pretty well (e.g. bash, zsh, sh on most machines) and it's pretty powerful.
We have been about four hours in the cave. That was definitely not the last time
I did that, but I need my own equipment next time.
"Public service broadcasters are compromising quality to compete with commercial channels, and many of them depend on Governments or political parties. Meanwhile, ever-larger concentrations are developing in the commercial sector, often with clear political affiliations."(Television across Europe report from OSI EUMAP) There's a guide to what I'm planning to do Real Soon Now: konekti la komputilon al televido If you want to get involved with radio instead, you could answer this call for help with rampART radio, from ram radio. I think they were interesting listening during G8 and on 7 July, but maybe they need a different approach for the rest of the time. RampART broadcast over the internet, which was how I listened. Many of the documents describing the internet are non-free, which is a silly silly pain. I've supported the petition about Problems with the IETF's copying permissions, by Simon Josefsson (author of libidn and gnutls) but I haven't done more yet. Moving to games, Sam Hocevar's post about Monsterz is unhappy with the difficulty of finding items for it:
"it makes me feel like coders are years ahead in terms of sharing their digital work for everyone to use and improve."He's not alone. Want a big example? Stuart Yeates noticed that ibiblio's torrents have poor copyright info. I've also spotted Sourceforge and BerliOS hosting non-free data in the past. That's really annoying: you can't adapt everything you download from them and you have to read the terms really closely if you want to develop free software. It surprises me that Sourceforge and BerliOS stick so closely to the FSF's software=programs myth. It might be surprising that ibiblio's torrents seem blind to copyright metadata, but it's probably little surprise that a European Commission group assumes that strong, standardised, zealously-enforced copy controls are The Only Way and has meant the EFF Urges Fresh Inquiry Into Ramifications of DRM. There's news of a peer-to-peer technology that honours copyright law, by Derek Sooman. Will it work? Will it support liberal copyright terms as well as Big Media Grabs? Might Big Media outdo ibiblio? I doubt it.
Next.