Delete Original Images from F-Spot and Rotate Using Exif Information

Tagged:  

Over the past couple weeks, my girlfriend and I spent a lot of time working on the photos from our Peru trip. Since we used F-Spot to do our photo editing, when we were done we had a couple of problems when it came to transferring the photos back to her computer which is running Vista.

The first problem was that when we rotated images with F-Spot, it simply changed the exif information for the photo, and didn't change the pixels of the photo themselves. This was fine when viewed in F-Spot because it is aware of exif information, and displays the photos correctly. However, when we transferred the files to her computer, we discovered that Vista does not take exif information into account on the OS level, nor does Picassa. As a result, we needed to somehow rotate the images that had exif information indicating a non-normal rotation.

The second problem we encountered is that in F-Spot when you edit a photo, it creates a second file with the edited photo, and leaves the original unchanged. So, if you edit file dsc00343.jpg, you get a second photo called dsc00343 (Modified).jpg. This is OK when in F-Spot, however, when we went to her computer, it was very hard for her to have ONLY the modified version of those photos, and to delete the originals (since the edited versions are better than the originals).

To solve the first problem, I used a couple of tricks. The first thing I did was to make a copy of the photos in case all went south.

mkdir backupPhotos
cp *.jpg *.jpeg backupPhotos
cd backupPhotos

Once that is done, we can begin rotating images. For this, we will need the jhead program.

sudo aptitude install jhead

Once that's installed, we rotate:
jhead -autorot  *.jpg *.jpeg

This will rotate all of the files that have unusual information in the exif orientation field.

Problem number one solved.

For problem two, we will need to isolate all of the photos that have been modified, and delete the originals. To do this, we will capitalize on the fact that the renamed images use the original pictures name in their name.

To begin with, we create a list of the photos that have been modified:

ls *.jpg *.jpeg | grep -i modified > modifiedImages.txt

Using awk, we can separate out the original name of the photos. The following commands will convert the ')' to '(' and will use the two '(' as a delimiters, returning the name of the file as the first field, and the .jpg or .jpeg as the third field. After that, it will remove any spaces from the file name, and will create a new file with a list of the modified pictures. It sounds complicated, but the final result should work:

tr ')' '(' < modifiedImages.txt > modifiedImages2.txt
cat modifiedImages2.txt | awk -F'(' '{print $1,$3;}' | sed 's/  //g' > modifiedImages3.txt

You should now have a file called modifiedImages3.txt that contains the name of all of the original photos. To delete the pictures in this list from the collection - permanently - run:

rm `cat modifiedImages3.txt`

You should now be able to transfer this entire directory of photos to another computer without rotation issues or duplicated photos.

Great post! I had the same problem. However, not f-spot. I'm not actually sure which program is the culprit (either gphoto or gwenview or kde's built-in rotation utility).

However, why not use digikam? That handles exif info correctly as far as I can tell.

I never tried out digikam before, but I just installed it and am playing with it now. It's pretty heavyweight, and has a lot of weird dependencies (kaddressbook, kdeprint, kmail, postfix, to name a few).

Trying it out, it looks like it hasn't imported any of the tags on my photos, so I think I am going to have to pass on it until it can do that. It looks rather powerful, but I'm not ready to re-tag everything (again).

Responding to one of your points though, in theory, the rotation through exif information is a good thing. It's just another thing that MS doesn't support properly, and so the rotation becomes necessary.

I also just discovered the most excellent Folder Export extension that does many of the above things. If you have created a collection of photos that need to be exported to another computer, turn on this extension, and it will allow you to export the most recent version of all selected photos, and will also auto-rotate.

Pretty slick. I wish I had found it six months ago.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.