Manchester Has Awesome People And Trams

I’d never been to Manchester but I was invited to go on what was a rather geeky day out, which involved lots of statistics and pretty graphs presented in Manchester Town Hall. The town hall is a most beautiful building and well worth a look in its own right. After a fascinating day we wandered out into the city and ended up in Piccadilly Gardens which was a hive of activity as they were preparing for the start of the Manchester International Festival; in particular for an event called “What Is The City But Its People?” which involved a giant catwalk and two massive screens. Well, as we were there anyway we decided to hang around and watch and we were very glad we did.

As people came along the catwalk, the screens showed us some beautiful portraits of them and told us a little about their life. From Stefan, who sells the Big Issue every day at Victoria station, to a Syrian refugee, a mother and her new baby, school children with dreams, lovers, bakers, an array of very well-behaved dogs and many, many more. A diverse community of people living their lives in a big city. Wow!

The next day we managed to find some time to explore the tram network, ostensibly to look for Eccles cakes in Eccles (be warned, there are none). However despite that, Manchester was an amazing city, and one I hope to see again.

Manchester

From Depart To Arrive Route
Exchange Square 14:47 St Peter’s Square 14:52 G/H
St Peter’s Square 15:01 Eccles 15:28 E
Eccles 16:50 St Peter’s Square 17:19 E
Piccadilly Gardens 18:52 Deansgate-Castlefield 19:03 E

 

Advertisements

Wrapping Text With ImageMagick

I’ve already explained that I wanted to create an image slide for a slideshow from some information in a spreadsheet. I decided to use ImageMagick and, in particular, the Wand library for python to help me.

As with all theatre projects this one is collaborative. The original concept for this was James’ and he’d created some examples by hand*. Each slide has some fixed elements and then information specific to the event. Using those he’s created some template images that contain the fixed elements, there are a number of templates depending on the type of event.

Basic SlideEach one has basically the same layout and the same (wavy) line which delineates where I can draw the event elements onto the slide. Then I add the date and time and the title of the event and who is presenting it. All of that is straightforward with either a Caption, or a Text element.

Image AreaThe more challenging part is the lower half of the slide. The spreadsheet contains a link to an event specific image in Google Drive, so I download the image data directly. I want the image to fit into, at most, roughly half of the remaining area, so I resize it keeping the aspect ratio but capping the height and width.

with Image(blob=image_data) as img:
    size = "{}x{}".format(max_width, max_height)
    img.transform(resize=size)
    img_height = img.height # save height
    img_width = img.width # save width
    main_img.composite(img, left=left, top=top)

Slide With Image

Now I want to display the description wrapped around the slide. ImageMagick will easily draw all sorts of amazing text effects (on one line) but text wrapping is more of a challenge. You can use a Caption to wrap text inside a rectangle, but my rectangle now has a corner taken out of it. Also I was asked to truncate the text at a sensible point (e.g. the end of a sentence) if it was too big to fit.

This is the point for some funky arithmetic. Firstly create a Drawing and set the Font you want to use on it. Now text is either going to be next to the picture (a narrow line) or underneath it (a wide one), so using the font size and the height available, and of course the actual image height and width, calculate how many lines you can fit of each width. Now we just need to split the text into that many lines each of the right length.

The simplest way to split the text is to use the python textwrap module but that requires you to specify a fixed maximum number of characters and my font isn’t monospaced. Instead I use the Draw module’s get_font_metrics to do the same job. It requires a dummy image for some reason.

words = para.split(" ")
lines = []
with Image(height=10, width=10) as img:
  line = words.pop(0)
  for word in words:
    line_width = draw.get_font_metrics(img, 
      line + " " + word).text_width
    if line_width < max_width:
      line = line + " " + word
    else:
      lines.append(line)
      line = word
  if line != "":
    lines.append(line)
return lines

Using this I can build up a list of lines of text. Firstly the narrow ones and then the wide ones, discarding any text that won’t fit. Then I can draw them onto the image line by line. Giving me a finished slide.Complete Slide

 

*James is also responsible for the spreadsheet that holds all this data. You should ask him about it, it’s awesomely clever.

From Spreadsheet to Slideshow with a Raspberry Pi

As well as actually spending time playing in the theatre I also occasionally get involved in various computer related projects for one. This particular project was to help set up a rolling slideshow of “coming soon” events that we can display in the foyer of the theatre.

Of course this project lends itself to a raspberry pi so I got mine out and started work. Everybody (it seems) creates a slideshow on their raspberry pi, so there are many solutions to choose from. In this case (you’ll see why in a minute) I wanted a slideshow that looped through pictures in a directory and automatically coped with pictures being added and deleted. For now I’m using Eye of Gnome which does this admirably but this can easily be replaced in future.

So where are the pictures coming from? Well that’s where this gets interesting. The list of upcoming events is kept and managed in a Google Spreadsheet so I needed to take this information and turn it into a set of images for the slideshow. As the information in the spreadsheet is regularly updated I wanted to write a python script that could be run regularly by a cron job to pick up changes and create the new slideshow images.

Google provide an API to Google Drive that allows access to files and file information and they provide a python library to access this.
I followed the instructions here to configure a developers account and then grant access to the APIs you need (in this case Drive and Sheets). I decided to use the OAuth for Server to Server authentication to avoid the need for human interaction, so the other thing I needed to do was to make sure that the service account has access to the files it needs. I did this by sharing the relevant files and directories in Drive with the service account’s email address. I only needed to grant view access to the files as we’re only ever reading the data.

Then on the pi I needed to install a few libraries, the Google API of course, a date parsing module and Image Magick to help create the images.

sudo apt-get install python-pip
sudo pip install --upgrade google-api-python-client
sudo apt-get install python-dev
sudo pip install ciso8601
sudo apt-get install libmagickwand-dev
sudo pip install Wand

Once that’s done I could write the script to download the data. The Google API documentation is full of example code so it’s easy to get this working.
Firstly I retrieve the modified time of the spreadsheet, using the Drive API, to see if it’s changed since we last ran. If it has then I download the data from the spreadsheet and check each row to see if it’s been updated (each row has a unique identifier and a last updated time-stamp). For each updated row I delete any existing image and generate a new one.
Finally I record locally the most recently updated time of the rows so I know when to start from next time.

Note (because it surprised me) that the latest updated time of a row might actually be later than the modified time of the file as there’s sometimes a couple of minutes delay before the file modified time is updated.

That really was all there was to it. Well, okay, there’s actually a few other things going on too, but that’s for another post perhaps.

 

 

 

Seaton Tramway And The Sea

Mystery trip out, getting up at silly o’clock in the morning, take my camera? Well yes, I’m always up for that.

So we went on an adventure (and a magical mystery tour) and ended up in Devon. I laughed when I saw were we were, because who doesn’t love trams. Even better this was a little tram line that runs down to the seaside (and back). You’ll see from the table below that we were determined to make good use of our day tickets.

Seaton Tramway

From Depart To Arrive Route
Colyton 12:30 Seaton 12:54
Seaton 14:00 Colyton 14:23
Colyton 14:50 Seaton 15:14
Seaton 17:00 Colyton 17:23

 

We also saw the sea (proof below), paddled in it, ate fish and chips and ice cream and had what was really a perfect day out by the seaside.Seaton Beach

Brussels Has Small Sights And Underground Trams

Brussels is a lovely city. It has beer, chocolate and lots to see. The first thing we saw (if you exclude the Atomium which we passed underneath of course) was Mini-Europe. This contains scale models of many famous sights in Europe, many of which I have seen (and usually photographed) the real one.

Brussels Tram MapIt also has trams. Some of those actually run underground, which was a real novelty for me. So here is the requisite list of tram journeys.

Saturday

From Depart To Arrive Route
Heysel 16:10 De Wand 16:20 7
De Wand 16:21 Gare du Midi 16:27 3
Gare du Midi 17:20 Merode 17:53 81

Monday

From Depart To Arrive Route
Merode 17:47 Germoir 17:57 81

Tuesday

From Depart To Arrive Route
De Brouckère 11:05 Gare du Midi 11:12 4
De Brouckère 13:15 Port de Hal 13:25 4

Much to my surprise (some of) the trams are made by Bombadier.

Learning Language As A Game

duolingoSo sometimes my Twitter feed points me to something really interesting. Recently it pointed me to an application called Duolingo. It can be used via the website but there are mobile applications for Android, Apple and Windows. It’s an application for learning languages (the name may give you a clue there) which encourages you to spend five minutes a day learning a new language.

The idea is simple. Play the game, translating simple words and phrases in both directions and gain experience points (‘XP’) which allow you to level up through the language. Learning new skills and (more importantly) completing ‘streaks’ of continuous days played gains you ‘Lingots’ an in-game currency which can buy you useful things (a timed test, or a streak-preserver for instance) or just a new outfit for the games mascot, a rather cute green owl. You can follow friends too, thus allowing you to see who has practised most this week and cheer them on when they are doing well.

There are a wide variety of languages available depending on the language you’re starting from. For English speakers not only are there the obvious candidates (French, Spanish and German) but more unusual options like Esperanto, Swahili or Klingon. The courses are effectively crowd sourced, people volunteer to create the content which means that enthusiasts create courses (hence the more unusual options).

I decided to give it a go and learn Welsh. The first lesson was surprisingly easy (possibly helped by the fact that my six-word grasp of Welsh already included “bore da” and “nos da”) and I was hooked. It is surprisingly addictive. Got five minutes to kill? I’ll just strengthen my skills a little then…

The mobile version is the most accessible way to use it but the notes on the lessons when you visit the website contain some useful grammar tips which I’m not sure how well I’m going to learn. I’m hoping the later lessons will use more complicated constructions and perhaps I’ll learn them by absorption then.

Nine weeks in though and I’m still having fun. “Dw i’n hoffi dysgu Cymraeg”* in fact. I can’t do anything useful with it yet, like read a book or watch S4C, but for now it’s still a fun little game to play.

* I like learning Welsh.

 

 

Hull Museums – More Tram Logos

Kingston-upon-Hull has an amazing set of City Museums. Entrance is free so there was no reason not to take a look. We managed to find time to visit The Streetlife Museum of Transport and the Hull and East riding Museum (briefly). I certainly hope when we go back we’ll find time to visit some of the others.

The transport museum was amazing with a period street, a carriage ride and a couple of lovely trams. A couple of new tram logos I’d not seen before:

Romans Go Home!

Romans Go Home!

The Hull and East Riding Museum was a little jaunt through history and certainly has some wonderful Roman mosaics and the best Roman street scene I’ve ever seen, complete with graffitti! Slightly more authentically, I should point out that “Cave Canem” made an appearance too.

The Ferens Art Gallery is of course temporarily closed, but we have plans to visit that when it reopens and hopefully then we’ll get a chance to visit some of the other places we’ve not yet seen.

The Power Of Sound Effects

There's a Triffid behind you...

There’s a Triffid behind you…

In any show sound effects are important. They can set the scene, provide atmosphere and cue the action. Getting that just right can make a huge impact; as I was reminded recently.

If you are of a certain age (and a sufficiently geeky mindset) then there is one sound effect that will be instantly recognisable to you, the menacing rattle of a triffid. I’m sufficiently geeky to currently have it as my text message tone*.

So imagine the scene: a family day out at the Living Rainforest, walking along shaded jungle paths, when apparently out of nowhere comes that deadly rattle. The young woman standing next to us looks round in alarm.
“What on earth was that?” she exclaims.
With a straight face, I reply “a Triffid” and stroll away; leaving her obviously none the wiser and not at all reassured. Round the corner there is laughter and high-fiving with the family, including of course the person who has been conveniently texting me at irregular intervals hoping for just this result.

Still, it just shows how effective that sound effect is. Even out of context it is scary and organic, even more so when watching the show. Sound engineers are often under appreciated, but listen out because what they do is important. Even that telephone doesn’t just ring itself you know!

*Thanks to my favourite sound engineer who gave it to me.

Budapest (With Tram)

I’ve been to Budapest many years ago (and believe me that really is another story) but in those days I knew not of trams and so we had used the metro to get around the city. This time however I wanted to ride on a tram. Time was short but I fitted one little journey in:

Budapest

From Depart To Arrive Route
Kossuth Lajos tér 15:41 Vígadó tér 15:46 2

Here are a few of the pictures I took of this lovely city.

Vienna – Trams

We’d been cruising along the Danube for several days. Each day had brought new locations and we had been toured round them. We had seen trams, we had even seen trolleybuses but there had been no chance to ride on any of them. So when we given basically the whole day free in Vienna I had only one real ambition, to ride on a tram.

Well, actually, I had another ambition, to see the snow globe museum and find a snow globe from the original snow globe manufacturers, but although we took the tram out there, they were closed on Fridays. Then we headed back, and after lunch went out to The Belvedere to see the Klimt paintings (“The Kiss” is really far more impressive in real life than in a poster). Then finally back into town for a little shopping before we headed back to the boat. And, for those of you are interested, I did manage to buy a snow globe from the original snow globe manufacturers as a present for someone very special.

Vienna

From Depart To Arrive Route
Shottentor 12:03 Antonigasse 12:20 42
Vinzenzgasse 12:46 Shottentor 13:05 40*
Shottentor 13:50 Shloß Belvedere 14:05 D
Shloß Belvedere 15:38 Schwarzenbergplatz 15:44 D
Schwedenplatz 17:14 Prater Hauptallee 17:28 1

*The 40 doesn’t actually go to Vinzenzgasse normally but it was diverted due to some kind of street festival.