Exemplo n.º 1
0
    def test_upload_png_image_without_transparency_should_store_image_as_jpg(
            self):
        cms = get_cms()
        self.m = cms.create_media_from_file(
            self.get_test_image_path('test.png'), 'Test')

        # verify it's a JPEG file
        img = open_image(self.m.original_path)
        self.assertEqual('test.jpg', self.m.filename)
        self.assertTrue(is_jpeg_image_object(img))
Exemplo n.º 2
0
    def test_upload_png_with_transparency_should_not_convert_image_to_jpg(
            self):
        cms = get_cms()
        self.m = cms.create_media_from_file(
            self.get_test_image_path('test_with_transparency.png'), 'Test')

        # verify it's still a PNG file with transparency layer
        img = open_image(self.m.original_path)
        self.assertEqual('test.png', self.m.filename)
        self.assertTrue(is_png_image_object(img))
Exemplo n.º 3
0
    def test_resize_image_with_exif_tag_should_auto_rotate(self):
        filename = self.get_test_image_path('EXIF_orientation_samples/right.jpg')

        img = open_image(filename)
        img = exif_auto_rotate_image(img)
        (width, height) = img.size

        # the input image size is actually 480x640, but since the system is
        # rotating the image by 90 degrees because of the EXIF orientation tag,
        # we would expect to find the image domensions 640x480
        self.assertEqual(width, 640)
        self.assertEqual(height, 480)
Exemplo n.º 4
0
 def test_should_ignore_if_no_transparency_layer_present(self):
     img = open_image(self.get_test_image_path('test.jpg'))
     self.assertFalse(self.has_transparency_layer(img))
     img = remove_image_transparency(img)
     self.assertFalse(self.has_transparency_layer(img))
Exemplo n.º 5
0
 def test_should_remove_transparent_layer(self):
     img = open_image(self.get_test_image_path('test-transparent.png'))
     self.assertTrue(self.has_transparency_layer(img))
     img = remove_image_transparency(img)
     self.assertFalse(self.has_transparency_layer(img))