Archive for September, 2007

Hacking the Printer

Look into my eyes, Brother (MFC420-CN)… repeat after me, “I still have ink left.”

This ink never runs out!

This ink never runs out!

I have a Brother MFC420-CN (multifunction printer) and it religiously cleans its heads as long as it is plugged in. This combined with the facts that it will not print unless it has ink and the cost of ink make for a pretty nice business plan for Brother. This is common practice with most budget bubble jets, I suppose, since I’m sure they lose some money on the ~$100 device. Even if you want to print in black, and you’re magenta is empty, it will refuse to print. I’m a little conflicted about how I feel about this, because Brother does provide open support for Linux, which is a good thing. Anyway, the solution is clear: trick the vile thing into thinking it has ink. In fact, all the times I’ve received the “replace ink” message, there has still been a little ink in the cartridge…. and after tricking it, you can still print in that colour (until it actually runs out, of course). Googling resulted in a post on a forum somewhere about applying a strip of black tape to the ink cartridge, but wasn’t very clear. After some trial and error, I hope this picture clarifies things. I guess the tape blocks light of some sort, which it uses to monitor ink level.

(Wasn’t really sure how to classify this post… don’t have a how-to category. I should upgrade to WP 2.3 and use tags….)

Unexpected Revival

Due to various other things, (some within my control, others not), I haven’t worked much on PhotoFile since I last posted. Some of these things continue to require some of my attention. I had planned to have a minimally usable version out by the end of September, but now I’m not sure that will happen.

One of these things has been my laptop. What’s that, you say? I thought you said your laptop was dead….? I did. Or, at least, I thought I knew what the problem was but I wasn’t able to open the laptop to take a peek. A couple days ago, my dad showed up and convinced me to call around about getting someone to fix it. After hearing that there was an $85 assessment fee, as well as $85/hr rate, I decided it was time to attempt to open it up again. We got to the same stage, which was removing all visible screws and it was still refusing to reveal it’s secrets. Lots of poking around resulting in lots of failure continued. Note: It’s fun prying off laptop keyboard keys! 😀 The first one was a little unnerving, because I wasn’t sure if it would break. And they’re like little puzzles to put back together!

Feeling discouraged, I decided to take a break. Now here’s where something truly magical happened. Seriously, I hope you’re sitting down for this: I focused my mind and used the vast powers of the Internet. I think it was maybe the first Google result for “taking apart Toshiba laptops” that led to me finding a picture and a short description for disassembling a different Toshiba laptop. Luckily, this was pretty much the same as mine. Soon, I was excitedly prying off a plastic strip above the keyboard, which revealed more screws! Jackpot!

triumphant!

So I’m happy to say, the problem was something that was loose and connected to the hard drive. After snapping it back in proper-like, everything seems to be working! The combo drive was also loose (caused by my last attempt). I’ve since done a fresh install/upgrade to Ubuntu Gutsy. Unfortunately, I’m missing my customized Xorg configuration file, so I can’t use the nVidia binary drivers quite yet. I forget what options I had to enable…. But the fact that I have a laptop again is pretty sweet! I was kind of lazy about re-assembling it, though. I wonder where these 7 screws are supposed to be….

nvidia and Compiz on Gutsy

With this recent revival of one in the family, I had to try out the latest 3D whiz-bang (compiz-fusion) on my laptop. I have an nVidia 16MB GeForce4 420 Go on my laptop. After lots of troubleshooting, it looks like the new drivers resolve all the issues I was having (no window borders, black windows, etc). Only one problem, those new universal drivers do not support my chipset. I’m guessing that means I will no longer get any proprietary driver updates… great. I might have to look at the nouveau project for any kind of 3d performance/stability in the future. Would be nice if nVidia decided to follow in AMD’s footsteps and open up their specs.

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. 🙂

Blogging with images and WordPress

One things that WordPress is sorely missing is basic image handling. Blogging with images should be fast. Previously, I had gone as far as writing a script that would take all images in a directory, resize them, create thumbnails, and output the required html that I would then paste into the editor. Before that, I used a plugin that would would automatically generate thumbs, and it was great for a while. Until I upgraded, and didn’t enable the plugin… if you go see those old pages, you’ll notice they’re broken. So WP either needs a plugin that doesn’t break when you don’t have it installed, or a default will-always-be-supported image plugin. Since the latter doesn’t exist, I looked for the former. I’ve been using Flexible Upload for a while now, and it’s made posting pictures WAY less painful. Un-installing the plugin won’t affect any pages, because it just generates static content. So that’s what I use and recommend for uploading a couple pictures to a personal WordPress blog. Any other suggestions?

Screenshots follow:

This plugin sits in the Upload area….

This plugin sits in the Upload area….
After uploading an image…

After uploading an image…
Clicking Send to editor

Clicking Send to editor

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

GThumb has mangled my photos

For quite a long time, I’ve primarily been using GThumb to manage my photos. It’s fast, did approximately what I needed it to do and had this great “Apply physical transformation” checkbox on the Rotate tool.

GThumb’s Rotate Images Tool

GThumb’s Rotate Images Tool

What this did, was look at the Orientation information in the photo (as recorded by some cameras) and try to automatically rotate the photo correctly. For the most part it seemed to work great. Sometimes, they didn’t display correctly in other software, and I thought that was the other software’s fault – worked fine in GThumb.

However, as I’m now writing a tool that does similar things, I’m discovering that the fault was actually GThumb’s. After rotating the photo, GThumb did not update the photo’s orientation information. This caused all other applications (Eye of Gnome, Nautilus – website out of date!, etc) that correctly read this information, to display the image rotated incorrectly. In subsequent versions, a feature was added to counter this: Tools->Reset Exif Information. Applying this tool to the affected photos would solve the problem, but seeing which photos are affected is NOT intuitive. Hopefully, PhotoFile will make this easier with a clear UI.

The Rotate tool in GThumb now correctly adjusts the photo’s orientation information after rotating it. Some of the discussion regarding the bug is … amusing.

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.

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! 😀 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! 😀 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’. 😛