示例#1
0
    def test_path_exists(self):
        """
        Tests :func:`colour_hdri.utilities.common.path_exists` definition.
        """

        self.assertTrue(path_exists(__file__))
        self.assertFalse(path_exists(''))
示例#2
0
    def test_path_exists(self):
        """
        Tests :func:`colour_hdri.utilities.common.path_exists` definition.
        """

        self.assertTrue(path_exists(__file__))
        self.assertFalse(path_exists(''))
示例#3
0
def convert_dng_files_to_intermediate_files(dng_files,
                                            output_directory,
                                            demosaicing=False):
    """
    Converts given *dng* files to intermediate *tiff* files using given output
    directory.

    Parameters
    ----------
    dng_files : array_like
        *dng* files to convert to intermediate *tiff* files.
    output_directory : str
        Output directory.
    demosaicing : bool
        Perform demosaicing on conversion.

    Returns
    -------
    list
        Intermediate *tiff* files.
    """

    intermediate_files = []
    for dng_file in dng_files:
        intermediate_file = re.sub('\.dng$', '.tiff', dng_file)

        if path_exists(intermediate_file):
            os.remove(intermediate_file)

        LOGGER.info('Converting "{0}" file to "{1}" file.'.format(
            dng_file, intermediate_file))

        raw_conversion_arguments = (RAW_D_CONVERSION_ARGUMENTS if demosaicing
                                    else RAW_CONVERSION_ARGUMENTS)
        command = [RAW_CONVERTER] + shlex.split(
            raw_conversion_arguments.format(dng_file),
            posix=(False if platform.system() in ('Windows',
                                                  'Microsoft') else True))

        subprocess.call(command)

        tiff_file = os.path.join(output_directory,
                                 os.path.basename(intermediate_file))
        if tiff_file != intermediate_file:
            if path_exists(tiff_file):
                os.remove(tiff_file)

            os.rename(intermediate_file, tiff_file)

        intermediate_files.append(tiff_file)

    return intermediate_files
示例#4
0
def convert_dng_files_to_intermediate_files(dng_files,
                                            output_directory,
                                            demosaicing=False):
    """
    Converts given *dng* files to intermediate *tiff* files using given output
    directory.

    Parameters
    ----------
    dng_files : array_like
        *dng* files to convert to intermediate *tiff* files.
    output_directory : str
        Output directory.
    demosaicing : bool
        Perform demosaicing on conversion.

    Returns
    -------
    list
        Intermediate *tiff* files.
    """

    intermediate_files = []
    for dng_file in dng_files:
        intermediate_file = re.sub('\.dng$', '.tiff', dng_file)

        path_exists(intermediate_file) and os.remove(intermediate_file)

        LOGGER.info('Converting "{0}" file to "{1}" file.'.format(
            dng_file, intermediate_file))

        raw_conversion_arguments = (RAW_D_CONVERSION_ARGUMENTS
                                    if demosaicing else
                                    RAW_CONVERSION_ARGUMENTS)
        command = [RAW_CONVERTER] + shlex.split(
            raw_conversion_arguments.format(dng_file),
            posix=(False
                   if platform.system() in ("Windows", "Microsoft") else
                   True))

        subprocess.call(command)

        tiff_file = os.path.join(
            output_directory, os.path.basename(intermediate_file))
        if tiff_file != intermediate_file:
            path_exists(tiff_file) and os.remove(tiff_file)
            os.rename(intermediate_file, tiff_file)

        intermediate_files.append(tiff_file)

    return intermediate_files
示例#5
0
def convert_raw_files_to_dng_files(raw_files, output_directory):
    """
    Converts given raw files to *dng* files using given output directory.

    Parameters
    ----------
    raw_files : array_like
        Raw files to convert to *dng* files.
    output_directory : unicode
        Output directory.

    Returns
    -------
    list
        *dng* files.
    """

    dng_files = []
    for raw_file in raw_files:
        raw_file_extension = os.path.splitext(raw_file)[1]
        dng_file = os.path.join(output_directory, os.path.basename(
            re.sub('{0}$'.format(raw_file_extension), '.dng', raw_file)))

        path_exists(dng_file) and os.remove(dng_file)

        LOGGER.info(
            'Converting "{0}" file to "{1}" file.'.format(raw_file, dng_file))

        command = [DNG_CONVERTER] + shlex.split(
            DNG_CONVERSION_ARGUMENTS.format(output_directory, raw_file),
            posix=(False
                   if platform.system() in ("Windows", "Microsoft") else
                   True))

        subprocess.call(command)

        dng_files.append(dng_file)

    return dng_files
示例#6
0
def convert_raw_files_to_dng_files(raw_files, output_directory):
    """
    Converts given raw files to *dng* files using given output directory.

    Parameters
    ----------
    raw_files : array_like
        Raw files to convert to *dng* files.
    output_directory : unicode
        Output directory.

    Returns
    -------
    list
        *dng* files.
    """

    dng_files = []
    for raw_file in raw_files:
        raw_file_extension = os.path.splitext(raw_file)[1]
        dng_file = os.path.join(
            output_directory,
            os.path.basename(
                re.sub('{0}$'.format(raw_file_extension), '.dng', raw_file)))

        if path_exists(dng_file):
            os.remove(dng_file)

        LOGGER.info('Converting "{0}" file to "{1}" file.'.format(
            raw_file, dng_file))

        command = [DNG_CONVERTER] + shlex.split(
            DNG_CONVERSION_ARGUMENTS.format(output_directory, raw_file),
            posix=(False if platform.system() in ('Windows',
                                                  'Microsoft') else True))

        subprocess.call(command)

        dng_files.append(dng_file)

    return dng_files
示例#7
0
def convert_raw_files_to_dng_files(raw_files, output_directory):
    """
    Converts given raw files to *dng* files using given output directory.

    Parameters
    ----------
    raw_files : array_like
        Raw files to convert to *dng* files.
    output_directory : unicode
        Output directory.

    Returns
    -------
    list
        *dng* files.
    """

    dng_files = []
    for raw_file in raw_files:
        raw_file_extension = os.path.splitext(raw_file)[1]
        dng_file = os.path.join(
            output_directory,
            os.path.basename(
                re.sub('{0}$'.format(raw_file_extension), '.dng', raw_file)))

        if path_exists(dng_file):
            os.remove(dng_file)

        logging.info('Converting "{0}" file to "{1}" file.'.format(
            raw_file, dng_file))

        command = [DNG_CONVERTER] + shlex.split(
            DNG_CONVERSION_ARGUMENTS.format(output_directory, raw_file),
            posix=not _IS_WINDOWS_PLATFORM)

        subprocess.call(command, shell=_IS_WINDOWS_PLATFORM)  # nosec

        dng_files.append(dng_file)

    return dng_files