jim-easterbrook / python-gphoto2

Python interface to libgphoto2
GNU Lesser General Public License v3.0
362 stars 59 forks source link

How to capture to a file with a predetermined name #14

Closed vertgo closed 8 years ago

vertgo commented 8 years ago

Let's say I am iterating between files 1-100, and i want to name them photo_001.jpg, photo_002.jpg what can I do to capture an image with a name I'm giving it, like the equivalent function on command line? I'm having a hard time finding something similar in the examples?

jim-easterbrook commented 8 years ago

I don't think you can control the file name used to store them on the camera. When you import to the computer you can store them under any name you like though. Something like this:

path = camera.capture(gp.GP_CAPTURE_IMAGE, context)
camera_file = camera.file_get(path.folder, path.name, gp.GP_FILE_TYPE_NORMAL, context)
camera_file.save('/home/vertgo/Pictures/photo_{:03d}.jpg'.format(shot_number))
vertgo commented 8 years ago

Thanks! I'll try it