Archive for September, 2007

EXIF.py and Image Orientation

I was really puzzled… and in fact, I’m still puzzled, but at least it works now.

Update: I’m a bit less puzzled now. I wasn’t using the correct version of EXIF.py (see comments). This post has been updated to correct any information. I also updated the CODE style because posting python code when whitespace is ignored is a little confusing. ^.^

I’m now using EXIF.py for loading EXIF information from photos for my little project, PhotoFile. Today, I wanted the image orientation information. Looking in the source of EXIF.py, you’ll find:


EXIF_TAGS={
...
0x0112: ('Orientation',
{1: 'Horizontal (normal)',
2: 'Mirrored horizontal',
3: 'Rotated 180',
4: 'Mirrored vertical',
5: 'Mirrored horizontal then rotated 90 CCW',
6: 'Rotated 90 CW',
7: 'Mirrored horizontal then rotated 90 CW',
8: 'Rotated 90 CCW'}),
...
0x9003: ('DateTimeOriginal', ),
...
}

So, I tried:


image = open("photo.jpg", "rb")
tags = EXIF.process_file(image)

Using tags["DateTimeOriginal"] works fine. But using tags["Orientation"] does not work. So finally (it took an unfortunate amount of time to do this), I tried:


for tag in tags.keys():
if "orientation" in str(tag).lower(): print tag

To correct the above, I’m a little lazy with composition, so it’s easier to just post some output from a python session:


>$ python
>>> import EXIF
>>> p = open("photo.jpg", "rb")
>>> tags = EXIF.process_file(p)
>>> for key in tags.keys():
... if "orientation" in str(key).lower() or \
... "datetime" in str(key).lower(): print key, ": ", tags[key]
...
EXIF DateTimeOriginal : 2006:03:19 14:22:40
Image DateTime : 2006:03:19 14:22:40
EXIF DateTimeDigitized : 2006:03:19 14:22:40
Image Orientation : Rotated 90 CCW

There is indeed no “Orientation” tag but there is an “Image Orientation” tag. The string “Image Orientation” appears nowhere in the source, and I couldn’t find any documentation on it. It looks like the tag keys are set by reading them from the EXIF information within the file appending the key to the classification (as pointed out by Shirley – see comments), but even the EXIF spec lists the tag as “Orientation”. If anybody knows why this is the case wants to clarify further, please post in the comments.

Conclusion

So if you’re using EXIF.py and want access to the image’s orientation, use “Image Orientation” for the key.

touch PhotoFile

So I’m going with the name PhotoFile for my new project. Clever, I know. Actually, not sure what exists out there already, like this or with a similar name. A quick google search didn’t reveal much. Either way, I’m sure nothing exists that is quite so perfect for ME (I’m incredibly selfish), and I think this will be a good learning experience, so I plan on getting it to a reasonably usable state, at least.

PhotoFile - so early it doesn’t have version numbers yet!

I liked the original left-to-rightness, as it visually led the user through the workflow; and that’s how I originally envisioned it. But the whole thing was getting too wide. So I’ve updated the GUI a bit (not final by any means) and I think this is looking better, for now. Open to ideas/suggestions, of course.

Since last upate, I’ve done some (much needed) code refactoring and cleaning up, added minimal Exif support using EXIF.py, and some GUI modifications (file list frame is resizable, added the filename below the thumbnails, moved the Original thumb above the Preview thumb). Most of it is still just GUI stuff and it’s not functional, but it’s getting to a point where I will easily be able to make a few things functional.


$ cat photofile.py | wc -l
470
$ cat photofile.py | grep FIXME | wc -l
24

It’s still just a wee little program. :)

Project()

I’m currently working on an idea I’ve been kicking around for a long time:

photofile 0.0000001

This is being done in Python and PyGTK. It’s mostly just GUI stuff at the moment (none of the operations are functional), as I’m learning GTK as I go. And even though I’ve done a bit of reading regarding Python, it’s gonna be my first real attempt with the language. Bottom line: progress will probably be slow. :P

Some big news for Open Source, recently.

Also, apparently I’m strange, because I like the new Nano.

Now, that I’ve got rid of a bunch of bloggy things, I’m gonna go outside and rollerblade for a bit on this awesome day. Will grab a drink and poke at my new project after a soon-to-be-required shower.

Love is in the air…

Two of my friends got married on August 25th, 2007. Congratulations to Kurtis and Nubia in São Paulo (sorry, I wasn’t able to attend), and Alex and Desiree in Vancouver (it was a very nice wedding). I’m happy for everyone! :D Also, within the same week, my big brother announced that he popped the question to his girlfriend of 6 (?) years and she said yes! The wedding will be next year. Not only that, but they’re gonna be parents! (I wanted to wait a little while before posting that bit.) This is pretty big news in my family! :D On that topic, Ben and Mayu should be daddy and mammy very soon… Happy times. :)

Hmmm… ‘Guess I’d better start swimmin’, or I’ll sink like a stone, For the times, they are a-changin’. :P

Don’t Throw Bottles!

Ticketmaster increased the cost by almost 50%

Jesse and I went to the Commodore Ballroom and saw Brian Jonestown Massacre, Saturday night. Doors opened at 8. I think we entered around 8:30, grabbed a drink and settled at a table at the front. We chatted while waiting for the opening band to come out. I think they came out around 9:30 or 9:45. The Hugs: a group of energetic kids that looked like they were still in highschool (which would make them younger than everyone in the audience) – but they were pretty decent. They finished around 10:30 maybe. We had got up for the last couple songs and decided to stay and secure a good spot for the main attraction. BJM should be coming out soon.

Some bodies meandered about the stage setting up equipment, towels, water, and a mighty stock of beer. Looked good. Any time now. Any moment… Oh wait, gotta move the guitar a little… pluck a few keys on the organ. Adjust the mic stand. Move the guitar again, maybe give it another tune. Wow, they were certainly in no rush it seemed, and most probably stoned. Finally, the lights dimmed, and almost immediately, a large portion of the audience lit up. A spooky loop (must be their entry music) was playing for what seemed forever…. and eventually, they finally came out. At this point, I’m guessing it was 11:30.

Anton, the lead singer (it’s basically his band), took a little while longer… and looked like he really didn’t want to be there. Clearly intoxicated, the first thing he said was something along the lines of, “Don’t throw anything at me. That’s the quickest way to get kicked out. We’ve hired a hundred skin heads that will kick the shit out of anyone that fucks with us. …We’re gonna play for you tonight because you really deserve it, don’t you? So just… enjoy the show.” The crowd, of course, loved them, and this behaviour is what’s expected from Anton. The music was awesome when they were playing, and I have to admit, the lead singer telling off members of the crowd and even his own band were particularly entertaining.

At one point, Frankie, one of the guitarists, started to say “You guys are the best audience we’ve ever had in Vancouver…” but he was cut off by Anton: “Frankie, sit down and shut the fuck up! I’m tuning my guitar!” I think that was the only thing any of the other band members ever said.

Requests were not being taken. People would yell out the names of their favourite song, and Anton would say, “We’re not taking requests, so fuck you.” or “I already told you we’re not doing requests! I request you shut the fuck up!”

The show was very entertaining, to say the least. It ended at 1:00. By the end, somebody from the audience did throw a bottle. I didn’t see what it hit or where it landed or what, but it’s safe to say Anton went on a bit of a rant, calling whoever threw the bottle to come up on stage so he could kick their ass. He did have a very valid point, though: “Don’t throw bottles.” Seriously people, don’t pay for tickets to see someone and throw bottles at them on stage. That’s dangerous and a good way to ruin the rest of the show for everyone else.

  • All of Brian Jonestown Massacre’s albums are available for free download on their website. I thought that was pretty damn cool and that’s one reason I decided to go when Jesse made the suggestion.
  • There’s an interview with Anton Newcombe that provides a little background and is a pretty interesting read.
  • A poor quality video on youtube of some clips from the night. At about 3:50 is some dialogue between Anton and the crowd that must have been after Jesse and I had left. In the description, it says the band was held up at the border. Shame. I’m sure some better quality videos will appear later.
  • A review in the Georgia Straight of a previous show in Vancouver. Sounds similar…. The “holy wall of noise” happened a couple times, where the band was just banging out the same piece of music letting it grow in loudness and intensity. This lasted for minutes at a time. It was very trance-like and very awesome.

Listening to both bands has reassured me of one thing: I should acquire a drum set when I obtain the means. For some reason, I think I’d really enjoy them. Maybe I just like the idea hitting things….

Metroid Prime 3: Corruption

So I got Metroid Prime 3: Corruption, for my Wii. The release date was listed as Aug 27th, so I went out to grab it late that day. However, Nintendo only ships on Tuesdays (for whatever reason) so I had to wait another day – what’s one more day, anyway? I haven’t played too much of the game yet, but I would have to agree with what most of the reviews are saying: it is awesome in nearly every way.

The controls are a big part of the awesome: well implemented Wii controls (thanks, Retro) make for the best console FPS experience I’ve ever had, only rivalled by the mouse and keyboard on pc. (Mouse and keyboard don’t lend themselves well to the couch, however.) Quickly changing Prime’s controls to the more sensitive “Advanced” mode, I find it hard to imagine anything coming as close to the mouse and keyboard in the living room. After taking a little while getting used to it, I found I was double-jumping around enemies and firing down at them while airborne with ease. I simply can’t imagine doing that on a dual analog control scheme. And a lot of the combat in Corruption takes advantage of this new found accuracy of the wiimote. I like the added immersion of the controllers representing each of Samus’ hands, even though at times it seems glitchy. Moving the wiimote backward (pull) and forward (push) when operating some controls, for instance, sometimes requires multiple attempts. Luckily, these situations are never in the heat of battle.. and when they work, they’re very satisfying.

Having read a couple reviewers’ comments on the game’s difficulty level being a little easier than the previous Metroid Prime games, I started on Veteran mode. A few puzzles have had me wondering around rooms for a while, but until this latest boss fight I’m on (the third boss, I believe), I haven’t really been out-performed by enemies too much. But wow this latest boss is really kicking my ass… after a few failed attempts, each getting a little closer, I decided to call it quits for the night. The boss fights are AWESOME, of course. :)

The game, in general, simply oozes polish – which makes sense, considering it was delayed nearly a year. The graphics are great and the frame rate is buttery smooth. There is quality voice acting and many nice in-game cinematics. Samus doesn’t talk, which is generally a good thing. This surge of other characters into the generally solitary you-alone-on-an-alien-planet Metroid universe is a bit of a mixed bag… Some of the added characters seem a little shallow and forced. There is some background provided through scanning objects and reading (optional) but a little more backstory on the other bounty hunters would be nice, for example – before first meeting them in the introduction.

Anyway, the game is fantastic, even though the original Prime blew people away more. Definitely not a casual game, which is a huge relief. But I’m trying to limit my time with it. A few hours a day, kinda thing. I haven’t actually played it for a couple days… Gotta get back there and beat that boss…. later tonight, I think. Oh yeah, I have to mention: Super Metroid, or Metroid 3, has been out on Virtual Console for a while, and that game is a classic.