ExifTools

I upgraded my Galaxy SII to a custom version of Android 4.0.4 Ice Cream Sandwich the other night, and it’s been brilliant – except for one little bug. If I go into the Gallery app, images on my microSD are in a semi-random order. If I tell Android to group by time, the problem becomes apparent: large numbers of images, always in contiguous blocks, are thought to have been taken between 1992 and 2018. I didn’t have an Android phone in 1992, and 2018 hasn’t happened yet – clearly, it’s a bug.

A quick search turned up this Google Code issue, which matches what I’m seeing exactly: GPS data is sometimes corrupted as it writes to the image. Worryingly, the bug dates back to at least Android 2.3 Gingerbread – which I can confirm, as the images in question were taken while the Galaxy SII was still running 2.3.4 – but Google promises a fix is incoming.

Here’s an example of the problem. The GPS Date tag from a non-corrupt image reads 2012:10:30 – year, month, day with a colon delimiter. The GPS Date tag from a corrupt image reads 0112:09:26 – a clearly invalid date which is confusing the heck out of the Gallery app. (You can check this out yourself with the command exiftool -gps:GPSDateStamp filename.jpg)

But why have I only just spotted the problem? Simple: the ICS – and Jelly Bean – Gallery app has changed its behaviour from previous versions. Where the old Gingerbread Gallery used to use the file modified date to sort the images, the ICS and newer Gallery uses the GPS Date Stamp tag from the EXIF data – the very tag that is being corrupted by the bug. Why it does that, I have no idea: there are numerous other EXIF tags which have the right date stamp and would be more appropriate for sorting, such as the Date Time (Original) tag. Perhaps that’s Google’s fix: modify the Gallery to sort on a different tag.

A pending fix doesn’t solve the fact that I’ve got a few hundred images with corrupt EXIF information, though. Switching to a third-party image viewer, like QuickPic, orders the images correctly, but that’s a workaround at best. So, I’ve written a quick tool to correct the invalid EXIF data on all my images.

It’s a bash shell script, and simple enough: it calls the ExifTool Perl package to copy the date from the Date Time (Original) tag over the top of the GPS Date Stamp tag. The result: the invalid tag goes away, Android knows what year the image was taken, and it orders the gallery correctly. It’s a hack: it overwrites the GPS Date Stamp of all JPG images in the current directory, regardless of whether the year makes sense or not, but it fixes the problem – albeit slowly.

You can find the script on GitHub. Hope it helps!

When you’ve corrected your images, you’ll need to go into Settings and Applications on your Android phone. Choose ‘All,’ find the Gallery app and tap it to get into the menu. Hit ‘Force Stop’ and then ‘Clear Data’ – don’t worry, you won’t lose any images, this just deletes the file database and thumbnail cache. If you don’t, the Gallery will still use the old ordering data and you’ll still have a problem. When that’s done, load the Gallery, let it find your files, and enjoy having all your images in the right order.

Oh, and one other thing: take a backup of your images before running the script. Although it worked fine for me, I can’t guarantee it won’t corrupt images further – and I don’t want to be responsible for you losing your precious photos.

Having finished my articles this morning, I figured it was time for an apt-get dist-upgrade on the laptop to ensure I was running the latest versions of everything.  A quick download and install later, and it was time to reboot.

At which point Firefox broke completely. No starty, no error – even when launched from the shell.

It’s taken me a little while, but I’ve tracked down the culprit: the Prism plugin.  If you’ve got Prism – a stand-alone Mozilla-based browser for creating desktop-style access to web apps – then the chances are you’ll be bitten by this bug, as installing Prism automatically installs the plugin into Firefox.

Thankfully, the fix is simple: go to Tools -> Add-Ons and disable Prism.

What’s that?  You can’t load Firefox in order to disable the Prism plugin?  There’s a fix for that, too.  Load a shell (Applications -> Accessories -> Terminal) and type:

cd ~/.mozilla/firefox
ls

That’ll give you a listing of the directory – with a single entry, which is your profile folder.  Use cd to change to this directory, then type:

rm compatibility.ini

Once you’ve done that, Firefox should start fine and you’ll be able to disable the add-on.

If you’re curious, there’s a bug filed on Launchpad over here.

I appear to have broken my netbook.

Well, ‘broken’ might be a bit steep – it no longer responds to a lid close event with the nice, neat standby mode it once treated me to.  Instead, it triggers the standby script and gets itself into a half-on, half-off state.

In this state, the power light is flashing to indicate that it’s in standby.  Unfortunately, it isn’t – everything’s still working fine.  The only indication that it even tried to standby is that my SD card unmount/remount script is triggered and the default keyring is locked.

Read More →