def test_gm_options_crop(self):
        image = ImageModelFactory.create()
        thumbnail = Thumbnail(image.file.path, {'size': ['100', '50'], 'crop': False})
        assert 'gravity' not in thumbnail.get_gm_options()
        assert 'crop' not in thumbnail.get_gm_options()

        thumbnail = Thumbnail(image.file.path, {'size': ['100', '50'], 'crop': True})
        assert list(thumbnail.get_gm_options().items()) == [
            ('+profile', '"*"'),
            ('resize', '50x25^'),
            ('gravity', 'Center'),
            ('crop', '50x25+0+0')
        ]
Ejemplo n.º 2
0
 def test_gm_options_quality(self):
     image = ImageModelFactory.create()
     thumbnail = Thumbnail(image.file.path, {
         'size': ['100', '50'],
         'quality': 5
     })
     assert thumbnail.get_gm_options()['quality'] == 5
Ejemplo n.º 3
0
 def test_gm_options_crop_gravities(self, crop, expected):
     image = ImageModelFactory.create()
     thumbnail = Thumbnail(image.file.path, {
         'size': ['100', '50'],
         'crop': crop
     })
     assert thumbnail.get_gm_options().get('gravity', None) == expected
Ejemplo n.º 4
0
    def test_gm_options_crop(self):
        image = ImageModelFactory.create()
        thumbnail = Thumbnail(image.file.path, {
            'size': ['100', '50'],
            'crop': False
        })
        assert 'gravity' not in thumbnail.get_gm_options()
        assert 'crop' not in thumbnail.get_gm_options()

        thumbnail = Thumbnail(image.file.path, {
            'size': ['100', '50'],
            'crop': True
        })
        assert list(thumbnail.get_gm_options().items()) == [
            ('+profile', '"*"'),
            ('resize', '50x25^'),
            ('gravity', 'Center'),
            ('crop', '50x25+0+0'),
            ('quality', 90),
        ]
Ejemplo n.º 5
0
    def test_gm_options_sizes(self, input_size, thumb_size, upscale, crop,
                              expected):
        image = ImageModelFactory.create(file__width=input_size[0],
                                         file__height=input_size[1])

        instance = Thumbnail(
            image.file.path,
            {
                'size': (str(thumb_size[0]), str(thumb_size[1])),
                'upscale': upscale,
                'crop': crop,
            },
        )

        assert_error = '{0} -> {1} (upscale: {3} crop: {2})'.format(
            input_size, thumb_size, crop, upscale)

        options = instance.get_gm_options()
        assert options.get('resize', None) == expected[0], assert_error
        assert options.get('crop', None) == expected[1], assert_error
    def test_gm_options_sizes(self, input_size, thumb_size, upscale, crop, expected):
        image = ImageModelFactory.create(
            file__width=input_size[0], file__height=input_size[1])

        instance = Thumbnail(image.file.path, {
            'size': (str(thumb_size[0]), str(thumb_size[1])),
            'upscale': upscale,
            'crop': crop
        })

        assert_error = '{0} -> {1} (upscale: {3} crop: {2})'.format(
            input_size,
            thumb_size,
            crop,
            upscale
        )

        options = instance.get_gm_options()
        assert options.get('resize', None) == expected[0], assert_error
        assert options.get('crop', None) == expected[1], assert_error
 def test_gm_options_quality(self):
     image = ImageModelFactory.create()
     thumbnail = Thumbnail(image.file.path, {'size': ['100', '50'], 'quality': 5})
     assert thumbnail.get_gm_options()['quality'] == 5