Exemplo n.º 1
0
 def test_jpeg_quality_filter_too_big(self):
     fil = Filter(spec='width-400|jpegquality-101')
     image = Image.objects.create(
         title="Test image",
         file=get_test_image_file_jpeg(),
     )
     self.assertRaises(InvalidFilterSpecError, fil.run, image, BytesIO())
Exemplo n.º 2
0
 def test_jpeg_quality_filter_too_big(self):
     fil = Filter(spec='width-400|jpegquality-101')
     image = Image.objects.create(
         title="Test image",
         file=get_test_image_file_jpeg(),
     )
     self.assertRaises(InvalidFilterSpecError, fil.run, image, BytesIO())
Exemplo n.º 3
0
    def test_jpeg_quality_filter_overrides_setting(self):
        fil = Filter(spec='width-400|jpegquality-40')
        image = Image.objects.create(
            title="Test image",
            file=get_test_image_file_jpeg(),
        )

        f = BytesIO()
        with patch('PIL.Image.Image.save') as save:
            fil.run(image, f)

        save.assert_called_with(f, 'JPEG', quality=40, optimize=True, progressive=True)
Exemplo n.º 4
0
    def test_jpeg_quality_filter_overrides_setting(self):
        fil = Filter(spec='width-400|jpegquality-40')
        image = Image.objects.create(
            title="Test image",
            file=get_test_image_file_jpeg(),
        )

        f = BytesIO()
        with patch('PIL.Image.Image.save') as save:
            fil.run(image, f)

        save.assert_called_with(f,
                                'JPEG',
                                quality=40,
                                optimize=True,
                                progressive=True)