Using rsync to download photos from camera 

I've been using rsync for many years to synchronize between local directories or remote PCs. I've also successfully used rsync to synchronize photos from my Pentax Optio camera to PC, so that only the newly shot photos are copied.

However, I found the very same approach doesn't work for the Canon camera:

$ rsync -nvua /mnt/camera/dcim/*/* .
building file list ... done
[...]
img_0135.jpg
[...]
$ stat /mnt/camera/dcim/100canon/img_0135.jpg img_0135.jpg
  File: `/mnt/camera/dcim/100canon/img_0135.jpg'
  Size: 892127          Blocks: 1792       IO Block: 32768  regular file
Device: 811h/2065d      Inode: 9817        Links: 1
Access: (0664/-rw-rw-r--)  Uid: ( 9999/    tong)   Gid: ( 1001/    tong)
Access: 2007-12-27 00:00:00.000000000 -0500
Modify: 2007-12-27 14:27:10.000000000 -0500
Change: 2007-12-27 14:27:10.000000000 -0500
  File: `img_0135.jpg'
  Size: 885981          Blocks: 1737       IO Block: 131072 regular file
Device: 80eh/2062d      Inode: 166857      Links: 1
Access: (0664/-rw-rw-r--)  Uid: ( 9999/    tong)   Gid: ( 1001/    tong)
Access: 2007-12-27 14:27:10.000000000 -0500
Modify: 2007-12-27 14:27:10.000000000 -0500
Change: 2007-12-27 21:53:41.000000000 -0500

I.e., rsync insists to copy again files that have already been copied, although I see no obvious reason why it is doing so.

Please comment.

Using rsync to download photos from camera 

On Mon, 31 Dec 2007 12:01:08 -0500, Wayne Topa wrote:

>> I.e., rsync insists to copy again files that have already been copied,
>> although I see no obvious reason why it is doing so.
>
> I use rsync, much like you do, to copy .debs to 4 other boxes.  I only
> use it like below, and only transfer the newer .deb files.
>
> rsync --ignore-existing *.deb

Ah, that sure will work. Best solution for this case.

thanks.

xpt

documented on: 2008-01-01

Digital photo handling on the command line Mini HOWTO 

Till Kamppeter

http://www.linuxprinting.org/download/digitalimage/

Here is described how very common tasks of digital photo handling can be done on the command line, this is especially interesting when one has to apply manipulations to several hundreds of photos, where using graphical applications can get a pain.

All operations described here are completely done with free software (My scripts below are GPL) and should work (assuming all needed software is installed) on all GNU/Linux systems.

All JPEG manipulations are done without recompression, so there is no loss of image quality.

Download photos 

[... content omitted ...]

Camera-specific/proprietary data formats 

Put photos in correct orientation (loss-less) 

Neads jhead, jpegtran, no JPEG recompression, so no quality loss

Automatically 

Works only with newer cameras with orientation sensor

$ jhead -autorot *.jpg

Manually 

$ jhead -cmd "jpegtran -rot 270 &i > &o" file.jpg   (90 degree left)
$ jhead -cmd "jpegtran -rot 90 &i > &o" file.jpg    (90 degree right)

Crop photos to 3:2 ratio 

Crop photos to 3:2 ratio (for filling 4x6in/10x15cm photo paper, loss-less) or any other ratio

[... content omitted ...]

Name photos by their capturing date/time 

E. g. for sequencializing photos from different cameras

$ jhead -n *.jpg

Correcting timezone 

To correct photos when you have forgotten to adjust the time of your camera when you were on travel (example here: photos taken in Portland/Oregon in the US, camera was on Central European Time). Very important is to do this in the two separate command lines as shown. Otherwise neither the file date will be set nor the file will be renamed.

$ jhead -ta-9 *.jpg
$ jhead -ft -n *.jpg  (leave out "-n" to not rename)

Shrinking photos for web/screen display 

Needs ImageMagick, NOTE: JPEG is recompressed, resolution is lowered, quality loss!

It is assumed that the long edge of the destination images should be 640 pixel. Replace all occurences of "640" by your desired length of the long edge (e. g. 1024) if you want to have another size. The photo is always resized to the biggest size which fits into the size given on the "convert" command line keeping the aspect ratio (for 4:3 images the size will be 640x480 for landscape or 480x640 for portrait images). The duplicate mention of the size on the command line is to increase performance, as the JPEG decoding of the input file is already done with the resizing in mind.

$ convert -size 640x640 file.jpg -resize 640x640 -quality 75 newfile.jpg

Automatic resizing of a series of images (with jhead):

$ jhead -cmd "convert -size 640x640 &i -resize 640x640 -quality 75 &o" *.jpg

Use this command only on copies of your images, it overwrites the original files.

Noise reduction 

Needs ImageMagick, NOTE: JPEG is recompressed, resolution is lowered, quality loss!

Modify the numerical value to optimize your results. The higher the value the more blurred gets the image, the lower the value the more of the noise still stays visible.

$ convert -noise 2 before.jpg after.jpg

or for a series of images

$ jhead -cmd "convert -noise 2 &i &o" *.jpg

Use this command only on copies of your images, it overwrites the original files.

Using these manipulations in gqview 

To quickly apply a certain task on the image currently visible in gqview, one can right-click the image and then choose "Edit" in the pop-up-menu. Currently here are only editing tools as GIMP, Electric Eyes, XV, etc. available, but the list can be customized by the user choosing "Edit" in the menu bar, and then "Options". In the upcoming dialog one goes to the "Editors" tab and enters the desired menu entry texts and commands. If a command requires the file name of the image, one inserts the placeholder "%f" at the appropriate place. It is very handy to add entries for the scripts "rotateleft" and "rotateright" shown below and "removebadpoints" shown above.

GIMP 

Some links for photo touch-up and enhancement tutorials (not all can be done automatically by applying command line tools or scripts):

Photo-specific: http://gimpguru.org/

General, but many photo-specific: http://mmmaybe.gimp.org/tutorials/

General: http://gimp-savvy.com/BOOK/index.html http://www.gimp.org/tutorials.html

Grain/noise remover: http://members.ozemail.com.au/~hodsond/degrain.html

GIMP - Red-Eye reduction 

You can easily remove red eyes in flash photos with the "redeye" GIMP plug-in. The nice thing in this plug-in is that you do not need to mark the red eyes exactly, the plug-in finds the borders of the red puplis by itself.

Remove bad pixels of the camera's image sensor 

Remove bad pixels due to defects in the image sensor of the camera

Needs jpegpixi. No JPEG recompression, so no quality loss

 Preparation: Has to be done once for every of your digital
cameras. Take a completely black photo by covering the lens and/or
setting the most close aperture and the fastest shutter speed, flash
off, focusing does not matter. Use the highest available JPEG quality,
RAW or TIFF.

jpegpixi contains a utility to automatically find the dead (stuck) pixels in the black frame. Its name is "jpeghotp" and works only on JPEG images. So convert your dark frame into a high quality JPEG image at first. Then run

jpeghotp blackframe.jpg deadpixels.txt

and there will be a list of the dead pixel coordinates, readable by jpegpixi in the deadpixels.txt file.

Alternatively, you can load the photo into the GIMP and zoom it by right-clicking and choosing "View"/"Zoom"/"1:1" to find the bad spots and "4:1" to easily determine the coordinates (visible in the lower left corner of the image window). The bad pixels are easy-to-see light spots on the black area. Note all coordinates. You can also use the "display" utility of ImageMagick. Here zoom the image and click onto the dead pixels with the middle mouse button to see their coordinates.

Now write a file deadpixels.txt with the coordinates of all bad spots as follows:

1348,838,6
713,1009,4

Every line is one bad spot or area. The first two numbers are the coordinates of the upper left corner of the bad area and the last number is the border length of a square covering the bad spot. Choose coordinates and size to make the bad area one or two pixels bigger all around. The bad spot gets somewhat blurred by the JPEG compression of the real photos. In the TIFF or RAW images the bad spot is absolutely sharp and therefore smaller.

Removing bad spots from one photo

$ jpegpixi orig.jpg fixed.jpg -f deadpixels.txt

or from all photos in the current directory

$ jhead -cmd "jpegpixi &i &o -f deadpixels.txt" *.jpg

This removes the bad spots by interpolating the colors of the environment to replace the spot.

Or make a little script ("removebadpoints") containing the lines

#!/bin/sh
jhead -cmd "jpegpixi &i &o 1348,838,6 713,1009,4" $*

and do

$ removebadpoints *.jpg

to clean every new set of photos in one simple step.

Remote Control for Canon Cameras 

Most Canon cameras can be fully remote-controlled with free software using the "capture" utility based in libptp2. Supported are all manual exposure settings and there is even a life viewfinder window.

documented on: 2007-12-27