Posts Tagged ‘Python’

(on Technorati , Del.icio.us)

Rhythmbox Jump-to-playing Plugin

This plugin will display the View : Jump to Playing Song link as a button in the toolbar and as link in the Browser’s context menu. This is about as simple as a plugin could be (which is partly why I wrote it), but I’ve actually found it quite useful. Maybe you will too.

jump-to-playing-0.1

Download

jump-to-playing-0.1.tar.gz (Update: Newer version is available.)

Installation

  1. Extract the jump-to-playing folder into your ~/.gnome2/rhythmbox/plugins/ directory.
  2. (Re)Start Rhythmbox and enable the plugin in Edit : Plugins.

Todo

  • Add Configure dialog with checkboxes for toolbar and browser context menu, defaulting to toolbar only (both is a little redundant). Currently, both are added automatically.
    [x] Add button to toolbar
    [_]Add link to browser context menu
  • Force “Properties” to bottom of browser context menu (may depend on placeholder being added to the context menu)
  • Hide toolbar button in Small Display mode.

Getting Tabs Closed

You know you’re trying to do too many things at once when…

ZOMG that’s a lot of tabs!

Managing browser tabs needs its own methodology, like GTD: Every week, go through your open tabs and close as many as you can. I don’t actually need to read that article. Not interested in this, any more. etc.

A bit better…  :-/

Clearly, I fail. >.< Restoring this session of 20 tabs brings Firefox up to 80MB, right away. Most of my current tabs are about different programming things: various references, tutorials, articles… as well as a tab to feedburner – for some reason, I’m addicted to looking at my blog’s meagre statistics. It’s fun!

Side Note: One thing that’s pretty cool, that can help minimize the tabs open for Python reference, is the Python sidebar. If there was only a pyGTK section in the sidebar….

When I’ve had tabs sitting open with no activity… I copy the link into a “would-be-nice” Tomboy note and close the tab. This helps a little… but I still have generally too many tabs open to help with the task at hand – and I prefer tabs to new windows (opening new windows is painfully slow on my setup, not sure why). If you have a similar problem of many tabs open at one time, I highly recommend the Tab Groups Firefox extension. Take a look:

Tab Groups Firefox Extension

Wow. The extension is still super early (I think it’s already caused FF to crash once), it takes a little while to sort the tabs when restoring a session, and you can’t move the Tab Groups around… but I’m definitely going to continue using it. It allows for much easier navigation of your current session, rather than scroll-click-is-this-what-i’m-looking-for-if-not-repeat. And for some reason, it even feels snappier! 😮 So this helps you Get Tabs Organized, which helps GTC, which helps GTD. Yay. 🙂

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.

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.