How to use the gphoto2.gp_file_save function in gphoto2

To help you get started, we’ve selected a few gphoto2 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github greiginsydney / Intervalometerator / Raspberry Pi / www / intvlm8r.py View on Github external
app.logger.debug('Added deleteAfterCopy flag to the INI file, after error : ' + str(e))
        except Exception as e:
            app.logger.debug('Exception thrown trying to add deleteAfterCopy to the INI file : ' + str(e))
        deleteAfterCopy = False
    
    for path in camera_files:
        sourceFolderTree, imageFileName = os.path.split(path)
        dest = CreateDestPath(sourceFolderTree, PI_PHOTO_DIR)
        dest = os.path.join(dest, imageFileName)
        if dest in computer_files:
            continue
        app.logger.debug('Copying {0} --> {1}'.format(path, dest))
        try:
            camera_file = gp.check_result(gp.gp_camera_file_get(
                camera, sourceFolderTree, imageFileName, gp.GP_FILE_TYPE_NORMAL))
            copyOK = gp.check_result(gp.gp_file_save(camera_file, dest))
            if ((copyOK >= gp.GP_OK) and (deleteAfterCopy == True)):
                gp.check_result(gp.gp_camera_file_delete(camera, sourceFolderTree, imageFileName))
                app.logger.debug('Deleted {0}/{1}'.format(sourceFolderTree, imageFileName))
        except Exception as e:
            app.logger.debug('Exception in copy_files: ' + str(e))
    return 0
github greiginsydney / Intervalometerator / Raspberry Pi / intvlm8r.py View on Github external
return 1
    app.logger.debug('Copying files...')

    if not os.path.isdir(PI_PHOTO_DIR):
        os.makedirs(PI_PHOTO_DIR)

    for path in camera_files:
        sourceFolderTree, imageFileName = os.path.split(path)
        dest = CreateDestPath(sourceFolderTree, PI_PHOTO_DIR)
        dest = os.path.join(dest, imageFileName)
        if dest in computer_files:
            continue
        app.logger.debug('Copying %s --> %s' % (path, dest))
        camera_file = gp.check_result(gp.gp_camera_file_get(
            camera, sourceFolderTree, imageFileName, gp.GP_FILE_TYPE_NORMAL))
        gp.check_result(gp.gp_file_save(camera_file, dest))
    return 0
github jim-easterbrook / python-gphoto2 / examples / copy-files.py View on Github external
return 1
    print('Copying files...')
    for path in camera_files:
        info = get_camera_file_info(camera, path)
        timestamp = datetime.fromtimestamp(info.file.mtime)
        folder, name = os.path.split(path)
        dest_dir = get_target_dir(timestamp)
        dest = os.path.join(dest_dir, name)
        if dest in computer_files:
            continue
        print('%s -> %s' % (path, dest_dir))
        if not os.path.isdir(dest_dir):
            os.makedirs(dest_dir)
        camera_file = gp.check_result(gp.gp_camera_file_get(
            camera, folder, name, gp.GP_FILE_TYPE_NORMAL))
        gp.check_result(gp.gp_file_save(camera_file, dest))
    gp.check_result(gp.gp_camera_exit(camera))
    return 0
github florisvb / multi_tracker / nodes / trigger_gphoto2_camera.py View on Github external
file_path = gp.check_result(gp.gp_camera_capture(
            self.camera, gp.GP_CAPTURE_IMAGE, self.context))
        print('Camera file path: {0}/{1}'.format(file_path.folder, file_path.name))

        print('Captured image')
        t = rospy.Time.now()
        time_base = time.strftime("%Y%m%d_%H%M%S_N" + self.nodenum, time.localtime())
        print time_base
        name = time_base + '_' + str(t.secs) + '_' + str(t.nsecs) + '.jpg'
        target = os.path.join(self.destination, name)

        print('Copying image to', target)
        camera_file = gp.check_result(gp.gp_camera_file_get(
                self.camera, file_path.folder, file_path.name,
                gp.GP_FILE_TYPE_NORMAL, self.context))
        gp.check_result(gp.gp_file_save(camera_file, target))
        #subprocess.call(['xdg-open', target])