.. title: #9 copy photos from USB PTP and rename with exiftool and compress
.. slug: 9-copy-photos-from-usb-ptp-and-rename-with-exiftool-and-compress
.. date: 2023-04-02 18:22:27 UTC+02:00
.. tags: photography, bash, exiftool, workflow
.. category: 
.. link: 
.. description: 
.. type: text


How to copy photos from USB PTP camera?
-----------------------------------------

If the camera is connecting to computer by USB and has set as a USB device, 
then we can copy those photos by gphoto2 and gphotofs.

You might need to unmount from a file manager if automounted as we need to
Make sure no other program (gvfs-gphoto2-volume-monitor) or kernel module (su
ch as sdc2xx, stv680, spca50x) is using the device and you have read/write 
access to the device.

.. code-block:: bash

    #sudo apt  install gphoto2 gphotofs

Look around 

.. code-block:: bash

    #gphoto2 --summary
    #gphoto2 --auto-detect
    #gphoto2 --list-ports
    #gphoto2 --list-cameras
    #gphoto2 --list-folders
    #gphoto2 --abilities

    There is 1 folder in folder '/'.
     - store_10000001
    There is 1 folder in folder '/store_10000001'.
     - DCIM
    There is 1 folder in folder '/store_10000001/DCIM'.
     - 129_FUJI
    There are 0 folders in folder '/store_10000001/DCIM/129_FUJI'.

Make a directory for mounting USB PTP camera 

.. code-block:: bash

    #mkdir /home/kusanagi/usbptp/

Mount USB PTP to the directory 

.. code-block:: bash

    #gphotofs /home/kusanagi/usbptp/

Copy photos which was created today to current directory 
    
.. code-block:: bash

    #find ~/usbptp/store_10000001/DCIM/129_FUJI/ -daystart -mtime 0 -exec sh -c "cp {} ." \;


Rename photos with exiftool
-------------------------------------------------------------

Today is 20230402.

.. code-block:: bash


	#sudo apt install libimage-exiftool-perl

	#mkdir /media/kusanagi/toshiba-pc-l200-1/20230402{,-smallres}/

	#exiftool '-FileName<${CreateDate}_${Exif:Model}_${filename}' -d %Y%m%d_%H%M%S -v1 *

Generate smaller resolution photos for sharing / backup
----------------------------------------------------------

.. code-block:: bash

	#find . -iname "*jpg" -exec sh -c  "mogrify -path /media/kusanagi/toshiba-pc-l200-1/20230402-smallres/ -quality 95  -resize 1440x1440  {} " \;

.. code:: bash

	#find . -iname "*jpg" -exec sh -c  "mogrify -path /media/kusanagi/toshiba-pc-l200-1/20230402-smallres/ -quality 95  -resize 1440x1440  {} " \;

Done, unmount gphotofs
--------------------------


.. code-block:: bash

    fusermount -u /home/bob/usbptp




