Beispiel #1
0
    def test_rack_form_clean_photo(self):
        from fixcity.exif_utils import get_exif_info
        from PIL import Image
        import os.path

        data = self.data.copy()
        # Jump through a few hoops to simulate a real upload.
        HERE = os.path.abspath(os.path.dirname(__file__))
        path = os.path.join(HERE, 'files', 'test_exif.jpg')
        content = open(path).read()
        photofile = TemporaryUploadedFile('test_exif.jpg', 'image/jpeg',
                                          len(content), None)
        photofile.write(content)
        photofile.seek(0)
        # Okay, now we have something like a file upload.
        data['photo'] = photofile
        form = RackForm(data, {'photo': photofile})
        self.assert_(form.is_valid())
        # Make sure it doesn't have a bad rotation.        
        self.assertEqual({},
                         get_exif_info(Image.open(photofile.temporary_file_path())))
Beispiel #2
0
 def test_exif_info(self):
     img = self._make_image('test_exif.jpg')
     info = exif_utils.get_exif_info(img)
     self.assertEqual(info['Make'], 'Apple')
     self.assertEqual(info['DateTime'], '2009:11:07 10:49:33')
     self.assertEqual(info['Orientation'], 6)
Beispiel #3
0
 def test_rotate_image_by_exif(self):
     img = self._make_image('test_exif.jpg')
     rotated = exif_utils.rotate_image_by_exif(img)
     self.failIfEqual(img, rotated)
     # Unfortunately PIL doesn't save exif info on new images...
     self.assertEqual(exif_utils.get_exif_info(rotated), {})
Beispiel #4
0
 def test_exif_info__no_info(self):
     img = self._make_image('test_no_exif.jpg')
     info = exif_utils.get_exif_info(img)
     self.assertEqual(info, {})