Monday, July 30, 2012

fixing incorrect dates in JPEGs on (x)ubuntu

Have you ever faced the problem of incorrectly set date in your camera?
I have, and realized it only after copying data to my laptop.

In my case year was set to previous one. For the solution description, please keep this in mind as I fix the date shift only, however the tools used could fix any other incorrect date setup as well.

Fixing it for the future pics is easy, just update your settings in camera, however how to fix it for the already created pics?
There are 2 places where date update is required:
- fix file properties as well as
- fix EXIF data.

Fixing file date
In linux it's easy. My case was I set up last year instead of this one => after having all the jpegs in one dir, I just ran:
touch -d '+0 year' *
(solution ideas were inspired by:

How to fix EXIF data?
Exiftool ( seems to do the job easily. Date shift feature using exiftool is described in more detail on:

I Instaled it first:
sudo apt-get install libimage-exiftool-perl
Moreover there are multiple dates in EXIF, to list them I ran this on the particular file (using exiftool):
exiftool -k IMGP0184.JPG | grep Date
File Modification Date/Time     : 2012:07:30 22:27:57+02:00
Modify Date                     : 2011:07:22 12:48:12
Date/Time Original              : 2011:07:22 12:48:12
Create Date                     : 2011:07:22 12:48:12
Date                            : 2011:07:22
Manufacture Date                : 2011:10:07
-- press RETURN --
To fix EXIF dates on all the relevant files I ran:
exiftool "-AllDates+=1:0:0 0:0:0" *.JPG
That should be it. Let's check the result rerunning the EXIF data listing command:
exiftool -k IMGP0184.JPG | grep Date
File Modification Date/Time     : 2012:07:30 22:28:16+02:00
Modify Date                     : 2012:07:22 12:48:12
Date/Time Original              : 2012:07:22 12:48:12
Create Date                     : 2012:07:22 12:48:12
Date                            : 2011:07:22
Manufacture Date                : 2011:10:07
-- press RETURN --
OK, that worked for me :) Hope it helps you as well.

One more thing, to cleanup backup files created by exiftool I ran following:
rm *.JPG_original

Monday, July 2, 2012

Panorama photo creation in an easy (lazy) way

Q: Have you ever faced the challenge of creating panorama from the set of photos? Did you try to create it manually using your favorite graphics editor? Did you face problem of spending too much time on that?

A: There might be a solution for you. It's called Hugin.

As the homepage ( says: "With Hugin you can assemble a mosaic of photographs into a complete immersive panorama, stitch any series of overlapping pictures and much more."

As I'm used to run my favorite programs on Linux as well as Windows, I like the fact that it's capable of running on both, moreover it's open source (which I'm really excited for).

OK, so how it works for me? Maybe some motivating/demotivating pics in the beginning. 
Shots show the views of Ramadevara Betta (Hill) in India I took

Still interested? Let's go then...

Adventure part
Take photos of your interest in a sequence.
My rules follow:
- take at least 2 rows one above each other (make the left-to-right / right-to-left sequence)
- if required, reorder pics after downloading them from camera
- make sure the pics overlap (to be able to identify conneciton points there), rule might be to overlap like 1/4 or up to 1/3 or so

Boring part
1. make sure you have Hugin installed and start it
2. click "1. Load Images..." button
3.  click "2. Align..." button,
4. then be veeery patient, depending on the pics quality and count it might take quite some time
5. after done, "Fast panorama preview is shown" where you can do some final addaptions on the panorama (I usually don't need to do here anything at all)
6. when done close it and click "3. Create panorama..." button
7. when done, you should have your panorama present in tif file
8. that's it

Problem solving
If you're unlucky you might experience the problem that process fails during point 4. No controll points are found and you get error in the aligning console saying: "An error happened while loading image : caught exception: bad allocation"
It seems I was not the only one facing the issue and finally solution has been found:!msg/hugin-ptx/HPt0lIFFRr0/3fwBzt-EUJMJ

Problem, based on the discussions, seems to be that cpfind process, one that tries to find the controll points crashes due to problems with memory management.
OK, for me however the fix was, to slow the process a bit down (as by default it seems to be running on 8 parallel threads) and use less threads (also less memory) for analysis.
I anyway preffer the idea of someone else doing the boring job (connecting the pics in this case) rather than me, regardless how long it will take him :)

All right, but how to decrease thread count?
1. go to menu "File" -> "Preferences"
2. go to "Control points detector" tab
3. choose "Hugin CPFind (Default)" and click "Edit..." button
4. update "Arguments" from "--multirow -o %o %s" to "--ncores=1 --multirow -o %o %s"
5. click "OK" buttons
6. I also restarted Hugin (not sure if required)

I tried with switch "--ncores=4" first, but that didn't work for me so I changed to "--ncores=1" and it finally solved/workarounded the problem

What's next?
If interested, give it a try and see.
Feel free to link your panororamas/experiences on creating these in comments :)