Beispiel #1
0
 def collect_scales(self):
     for scale in SCALES['ICONS']:
         if getattr(self, scale.lower(), None):
             self.add_scale(scale,
                            convert(getattr(self, scale.lower()), scale))
         else:
             self.add_scale(scale, convert(self.base, scale))
Beispiel #2
0
 def test_converts_svg_base(self):
     self.assertImage(
         convert(source, 'BASE'), 1, 1, 'svg',
         '<?xml version="1.0" encoding="UTF-8"?>\n'
         '<svg width="1px" height="1px" viewBox="0 0 1 1" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">\n'
         '    <g id="logo"></g>\n'
         '</svg>\n')
Beispiel #3
0
    def test_converts_multipart_images(self):
        img = convert(source, 'FAVICON')
        self.assertEqual(len(img.sequence), 3,
                         'Should contain three subimages in the sequence')

        self.assertImage(img.sequence[0], 16, 16)

        self.assertImage(img.sequence[1], 32, 32)

        self.assertImage(img.sequence[2], 48, 48)
Beispiel #4
0
 def collect_scales(self, base_img):
     for scale in SCALES['ICONS']:
         self.add_scale(scale, convert(base_img, scale))
Beispiel #5
0
 def test_converts_png_fixed_aspect_ratio(self):
     self.assertImage(convert(source, 'LOGO'), 80, 80, 'png')
Beispiel #6
0
 def test_converts_png_fixed_size(self):
     self.assertImage(convert(source, 'APPLE_TOUCH_ICON'), 180, 180, 'png')
Beispiel #7
0
    def test_rejects_unsupported_types(self):
        with self.assertRaises(Exception) as context:
            convert(source, 'UNKNOWN')

        self.assertTrue('scale: UNKNOWN is not supported' in context.exception)
Beispiel #8
0
 def test_converts_multipart_images(self):
     img = convert(base, 'FAVICON')
     self.assertEqual(img['sequence_length'], 3,
                      'Should contain three subimages in the sequence')
Beispiel #9
0
def collect_logos(config):
    for scale in SCALES['LOGOS']:
        config.add_scale(scale, convert(config.base, scale))
Beispiel #10
0
def collect_icons(config):
    for scale in SCALES['ICONS']:
        config.add_scale(scale, convert(config.base, scale))