Marc's Public Blog - Misc Public Entries

All | Arduino | Btrfs | Cars | Clubbing | Diving | Electronics | Exercising | Flying | Hiking | Linux | Linuxha | Public | Rc | Snow | Solar | Trips
Generated on 2014-08-24 11:15:19 by Rig3 0.4-440



>>> Back to post index <<<

2006/09/19 How to convert raw cr2 pictures with linux, and merge pictures by date and Exif data with jhead
π 2006-09-19 14:07 by Merlin in Public

I recently went to an event with a coworker who took pictures with an SLR Canon Camera that took cr2 raw pictures. My goal was to convert them to jpeg, and integrate them with my own pictures (merging/interleaving them by date using the picture data inside cr2 and Exif for my jpegs)


Here were the steps:

  1. Convert all the cr2 pictures to jpeg
    You need to install dcraw , and then after reading the man page, I figured this would be a decent command that would work for most pictures:
    for i in *.cr2; do dcraw -c -q 0 -B 2 4 -w -H 5 -b 8 $i | cjpeg -quality 80 > $i.jpg; done
    (cjpeg comes from libjpeg-progs )
  2. Set the cr2 file time to the cr2 picture date inside the file:
    for i in *.cr2; do dcraw -z $i; done
  3. Set the file date on the jpegs to match the cr2 dates: for i in *.cr2; do touch -r $i $i.jpg; done
  4. Find a matching picture between both picture sets, and compute the offset between both cameras (it should be 0 in an ideal life, but real life is usually lees than ideal :). ls -l image.cr2 vs jhead image.jpg will give you the times for each picture
  5. Temporarily offset the time in the jpeg pictures that didn't come from cr2, like so: jhead -ta-4:55 *.jpg
  6. If you only had jpeg pictures, all with Exif data, you could use jhead -n *.jpg to rename them all so that they sort by date, but here we'll have to use the file times to sort them, so we'll ask jhead to set the Exif time as a modification date for the pictures that were jpegs to start with: jhead -ft *.jpg
  7. By then you can now merge both sets of pictures in the same directory, and you can then use the program of your choice to rename them by filenames that are sorted in the same order than the filenames ls -ltr *.jpg should list
    the pictures in the order they were taken
  8. I personally use midnight commander (mc), go to the picture directory, select 'sort order' by time, select all the files with + and enter, and put them all on the command line for rename with rename -y mergedpicts 100 CTRL-X T , rename being a special script of mine (follow the link to download)

And that's it, after all those *cough*simple*cough*easy*cough* steps, you end up with a bunch of jpegs ordered chronogically.

The end result of all this work was my picture library of pictures from the Reno Air Races

More pages: July 2014 April 2014 March 2014 February 2014 October 2013 May 2013 April 2013 January 2013 October 2012 September 2012 August 2012 July 2012 May 2012 April 2012 February 2012 December 2011 November 2011 August 2011 July 2011 April 2011 March 2011 December 2010 November 2010 October 2010 August 2010 July 2010 June 2010 April 2010 March 2010 February 2010 December 2009 November 2009 October 2009 September 2009 August 2009 June 2009 May 2009 April 2009 March 2009 February 2009 January 2009 December 2008 November 2008 October 2008 June 2008 May 2008 April 2008 March 2008 November 2007 October 2007 September 2007 May 2007 March 2007 December 2006 November 2006 October 2006 September 2006 August 2006 June 2006 May 2006 February 2006 January 2006 December 2005 November 2005 October 2005 October 2004 August 2004 June 2004 May 2004 March 2004 September 1997 July 1996 September 1993 July 1991 December 1988 December 1985 January 1980

>>> Back to post index <<<