示例#1
0
def read_exif_tags(image):
    """
    Returns given image exif image tags.

    Parameters
    ----------
    image : unicode
        Image file.

    Returns
    -------
    defaultdict
        Exif tags.
    """

    LOGGER.info("Reading '{0}' image exif data.".format(image))

    exif_tags = vivification()
    lines = unicode(subprocess.check_output(
        [EXIF_EXECUTABLE, '-D', '-G', '-a', '-u', '-n', image]),
        'utf-8', 'ignore').split('\n')

    for line in lines:
        if not line.strip():
            continue

        group, identifier, tag, value = parse_exif_data(line)
        exif_tags[group][tag] = (value, identifier)

    return exif_tags
示例#2
0
def read_exif_tags(image):
    """
    Returns given image exif image tags.

    Parameters
    ----------
    image : unicode
        Image file.

    Returns
    -------
    defaultdict
        Exif tags.
    """

    LOGGER.info("Reading '{0}' image exif data.".format(image))

    exif_tags = vivification()
    lines = text_type(
        subprocess.check_output(
            [EXIF_EXECUTABLE, '-D', '-G', '-a', '-u', '-n', image]), 'utf-8',
        'ignore').split('\n')

    for line in lines:
        if not line.strip():
            continue

        group, identifier, tag, value = parse_exif_data(line)

        if not exif_tags[group][tag]:
            exif_tags[group][tag] = []

        exif_tags[group][tag].append(ExifTag(group, tag, value, identifier))

    return exif_tags
示例#3
0
    def test_vivification(self):
        """
        Tests :func:`colour_hdri.utilities.common.vivification` definition.
        """

        vivified = vivification()
        vivified['my']['attribute'] = 1
        self.assertIn('attribute', vivified['my'].keys())
        self.assertEqual(vivified['my']['attribute'], 1)
示例#4
0
    def test_vivification(self):
        """
        Tests :func:`colour_hdri.utilities.common.vivification` definition.
        """

        vivified = vivification()
        vivified['my']['attribute'] = 1
        self.assertIn('attribute', vivified['my'].keys())
        self.assertEqual(vivified['my']['attribute'], 1)
示例#5
0
    def test_vivified_to_dict(self):
        """
        Tests :func:`colour_hdri.utilities.common.vivified_to_dict` definition.
        """

        vivified = vivification()
        vivified['my']['attribute'] = 1
        vivified_as_dict = vivified_to_dict(vivified)
        self.assertIsInstance(dict(), type(vivified_as_dict))
        self.assertIn('attribute', vivified_as_dict['my'].keys())
        self.assertEqual(vivified_as_dict['my']['attribute'], 1)
示例#6
0
    def test_vivified_to_dict(self):
        """
        Tests :func:`colour_hdri.utilities.common.vivified_to_dict` definition.
        """

        vivified = vivification()
        vivified['my']['attribute'] = 1
        vivified_as_dict = vivified_to_dict(vivified)
        self.assertIsInstance(dict(), type(vivified_as_dict))
        self.assertIn('attribute', vivified_as_dict['my'].keys())
        self.assertEqual(vivified_as_dict['my']['attribute'], 1)