Ejemplo n.º 1
0
    def test_parse_exif_numeric(self):
        """
        Tests :func:`colour_hdri.utilities.exif.parse_exif_numeric` definition.
        """

        exif_tag = ExifTag('EXIF', 'Focal Length', '16', '37386')
        self.assertEqual(parse_exif_numeric(exif_tag), 16)

        exif_tag = ExifTag('EXIF', 'Focal Length', '16', '37386')
        self.assertIsInstance(parse_exif_numeric(exif_tag, np.int_), np.int_)
Ejemplo n.º 2
0
    def test_parse_exif_fraction(self):
        """
        Tests :func:`colour_hdri.utilities.exif.parse_exif_fraction`
        definition.
        """

        exif_tag = ExifTag('EXIF', 'Exposure Time', '0.01666666667', '33434')
        self.assertAlmostEqual(
            parse_exif_fraction(exif_tag), 0.01666666, places=7)

        exif_tag = ExifTag('EXIF', 'Exposure Time', '10/4000', '33434')
        self.assertAlmostEqual(
            parse_exif_fraction(exif_tag), 0.00250000, places=7)

        self.assertIsInstance(parse_exif_fraction(exif_tag, np.int_), np.int_)
Ejemplo n.º 3
0
    def test_parse_exif_string(self):
        """
        Tests :func:`colour_hdri.utilities.exif.parse_exif_string` definition.
        """

        exif_tag = ExifTag('EXIF', 'Make', 'Canon', '271')
        self.assertEqual(parse_exif_string(exif_tag), 'Canon')
Ejemplo n.º 4
0
    def test_parse_exif_array(self):
        """
        Tests :func:`colour_hdri.utilities.exif.parse_exif_array` definition.
        """

        exif_tag = ExifTag(
            'EXIF',
            'Color Matrix 1',
            ('0.5309 -0.0229 -0.0336 '
             '-0.6241 1.3265 0.3337 '
             '-0.0817 0.1215 0.6664'),
            '50721')  # yapf: disable
        np.testing.assert_array_equal(
            parse_exif_array(exif_tag),
            np.array([
                0.5309, -0.0229, -0.0336,
                -0.6241, 1.3265, 0.3337,
                -0.0817, 0.1215, 0.6664]))  # yapf: disable

        np.testing.assert_array_equal(
            parse_exif_array(exif_tag, shape=(3, 3)),
            np.array([
                [0.5309, -0.0229, -0.0336],
                [-0.6241, 1.3265, 0.3337],
                [-0.0817, 0.1215, 0.6664]]))  # yapf: disable
Ejemplo n.º 5
0
def read_dng_files_exif_tags(dng_files,
                             exif_tags_binding=DNG_EXIF_TAGS_BINDING):
    """
    Reads given *dng* files exif tags using given binding.

    Parameters
    ----------
    dng_files : array_like
        *dng* files to read the exif tags from.
    exif_tags_binding : dict_like
        Exif tags binding.

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

    dng_files_exif_tags = []
    for dng_file in dng_files:
        exif_tags = read_exif_tags(dng_file)
        binding = deepcopy(exif_tags_binding)
        for group, tags in binding.items():
            for tag in tags:
                exif_tag = exif_tags[group].get(tag)
                parser = binding[group][tag][0]
                if exif_tag is None:
                    default = binding[group][tag][1]
                    binding[group][tag] = (
                        default if default is None else parser(
                            ExifTag(value=binding[group][tag][1])))
                else:
                    binding[group][tag] = parser(exif_tag[0])

        dng_files_exif_tags.append(binding)

    return dng_files_exif_tags
Ejemplo n.º 6
0
    def test_read_exif_tags(self):
        """
        Tests :func:`colour_hdri.utilities.exif.read_exif_tags` definition.
        """

        test_jpg_image = filter_files(FROBISHER_001_DIRECTORY, ('jpg', ))[0]
        exif_data = vivified_to_dict(read_exif_tags(test_jpg_image))

        self.assertIsInstance(exif_data, type(dict()))

        self.assertListEqual(sorted(exif_data.keys()), [
            'Composite', 'EXIF', 'ExifTool', 'File', 'ICC_Profile', 'JFIF',
            'Photoshop', 'XMP'
        ])

        self.assertListEqual(
            sorted(exif_data['EXIF'].values()),
            [[ExifTag('EXIF', 'Camera Model Name', 'EOS 5D Mark II', '272')],
             [ExifTag('EXIF', 'Create Date', '2015:09:19 03:39:20', '36868')],
             [ExifTag('EXIF', 'Date/Time Original',
                      '2015:09:19 03:39:20', '36867')],
             [ExifTag('EXIF', 'Exif Image Height', '426', '40963')],
             [ExifTag('EXIF', 'Exif Image Width', '640', '40962')],
             [ExifTag('EXIF', 'Exposure Time', '0.125', '33434')],
             [ExifTag('EXIF', 'F Number', '8', '33437')],
             [ExifTag('EXIF', 'Focal Length', '16', '37386')],
             [ExifTag('EXIF', 'ISO', '100', '34855')],
             [ExifTag('EXIF', 'Make', 'Canon', '271')],
             [ExifTag('EXIF', 'Modify Date', '2015:09:19 03:39:20', '306')],
             [ExifTag('EXIF', 'Orientation', '1', '274')],
             [ExifTag('EXIF', 'Photometric Interpretation', '2', '262')],
             [ExifTag('EXIF', 'Resolution Unit', '2', '296')],
             [ExifTag('EXIF', 'Software', 'Photos 1.0.1', '305')],
             [ExifTag('EXIF', 'X Resolution', '72', '282')],
             [ExifTag('EXIF', 'Y Resolution', '72', '283')]])  # yapf: disable