Posts Tagged ‘Development’

(on Technorati , Del.icio.us)

Wasn’t in my plans, but…

So I haven’t been working too much on PhotoFile, like wanted to, but I haven’t really been unproductive, either. Giving in to my friend’s incessant nagging to play (and thus, set up) UFO2000 on my computer, I updated the Ubuntu set-up guide I wrote on the forums after doing it again with the latest version on both my laptop (Gutsy beta) and my desktop (Feisty). I’ve played a couple games, so far, and they’ve been fun. But it still doesn’t work flawlessly. On my laptop, with default Gutsy settings, ALSA is used to access the audio. UFO2K uses the Allegro game programming library, and it accurately detects and plays sound on my laptop. However, there is a huge memory leak somewhere when running on my laptop (known issue, I think). Luckily, the game is saved on the server, so if you crash, you can log back in and you have the option of resuming the game. Cool.

On the Desktop side of things, there’s no memory leak, but it doesn’t work with the PulseAudio sound server. This irritated me last time I was looking at UFO2K and put me off of it, but this time, I was determined to figure out what the problem was, exactly. First of all, the problem can be resolved by killing the pulseaudio (pulseaudio -k) daemon before launching the game. But that may mess with your existing applications a little and it’s annoying. Good news: I think I found what the problem was. Bad news: I’m not sure when or if it will be fixed, but the developers are at least aware of it and started talking about it.

I don’t normally do much low-level stuff, so I actually learned quite a bit from the debugging. Unfortunately, I don’t have massive amounts of code to show for my efforts, but I’ve learned a lot and a potentially important bug has been well-documented. So it was well worth it. These are some of the things I did when debugging this problem:

  • Communicated with both PulseAudio and Allegro developers on bug trackers, mailing lists, and IRC.
  • Built the Allegro source and used my own custom (debug-enabled) version without disrupting the installed stable version.
  • Attempted to debug using ‘gdb’ mode in emacs, but I was never able to jump into the ALSA specific functions. I think the debugger wasn’t able to trace the threads as they were mapped with pre-processor statements according to the sound driver. I was able to switch to the thread, but the debugger couldn’t find the associated source, which made stepping rather pointless.
  • Eventually giving up on the fancy way, (but content I had learned something) I resorted to good ‘ol printf statements, and was eventually able to find the values (I think) are causing the problems. (Allegro uses unsigned sample formats, and PulseAudio doesn’t support those.)

I must say, using gdb in emacs is much easier than on the command line (but then, maybe ddd or another graphical debugger is nicer still, depending on how often you debug things). Okay, directing my attention back over to PhotoFile…. Or maybe upgrading WordPress…. or maybe…. ๐Ÿ™‚

PhotoFile

Screenshot update! Still no version… as it’s still just a husk of a UI… mostly.

PhotoFile pre versioning

I’ve changed the GUI quite a bit. Actually, what it is now took a surprisingly long time to arrive at. I spent time going through some ideas on paper, and I even did a huge amount of refactoring to make coding easier. It’s at the point where a GUI in another API could easily be thrown in…. it just requires me separating the PhotoFile class into PhotoFile and PhotoFileGTK… but I’m not going to bother, at this point, because I don’t think there’s much point in offering it in another kit. GUI and no-GUI could be useful, though. Anyway, there’s still quite a few problems remaining, including:

  1. Supported File Types: I need a list of file types (extensions) that are common in Cameras and that people would be interested in transferring. So far, I’ve got what my camera supports: JPG, THM, AVI, and WAV. Some cameras allow for sound recordings to be created (WAVs on mine) but I’m not sure what I should do with these… rename to have the same name as the image, I guess (if it’s a memo). Post your camera’s formats and how they’re used in the comments! Example of my Camera: WAV files with a filename the same as an image are a sound memo for that image. AVIs are movies and have and accompanying THM file (same filename) which is a small Jpeg containing a thumbnail of the movie.
  2. Empty Source Directories: When moving files from the source, should I automatically remove any empty source directories? Maybe add an advanced property for this? I certainly don’t want to add it to the main dialog. KISS.
  3. Separate Operations: I’m not sure if each file should save it’s own set of operations for the session. For example, user selects manual rotation for two files, and auto-rotation for the rest. Should Process All Files remember those two files’ manual rotation, or should it apply the visible operations to ALL files. If I should save settings for each file, then I feel like I’d need another button, Process All Files Using These Operations, just to be clear… maybe a “Reset to defaults” somewhere… sounds like too much clutter, but it could be useful for people whose camera’s don’t store EXIF. Suggestions?
  4. Manual Rotation: Need a dropdown or something for Manual rotation! Probably: {Left, Right, 180} or… a button Rotate 90 CW that when clicking, rotates the preview 90 degrees, clockwise. I kind of like that idea… super simple. To rotate “left”, the user would quickly learn that 3 quick clicks is quite fast.
  5. White Space: I think I need a little more white-space between the different sections.
  6. Functionality!
  7. Camera’s dying? Oh noes! I love my Canon IXY 400, but I’ve recently been getting a very ominous Memory Card Error message, more frequently. It worries me.

Aside from these things, I think I’m pretty satisfied with the current UI.

Still a tiny app, and still lots of things to do! ๐Ÿ˜€


$ cat photofile.py | wc -l
792
$ cat photofile.py | grep FIXME | wc -l
25

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. ๐Ÿ˜›

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.