def test_image_can_be_saved(self):
        image1 = Image(get_absolute_path('country/flags/bra.png'))
        image2 = Image(get_absolute_path('country/flags/can.png'))
        image3 = Image(get_absolute_path('country/flags/usa.png'))
        out_image = OutputImage(48 * 3, 48)
        out_image.add(image1, 0, 0)
        out_image.add(image2, 48, 0)
        out_image.add(image3, 96, 0)

        path = 'country/flags/sprite.png'
        absolute_path = os.path.join(settings.MEDIA_ROOT, path)
        try:
            out_image.save(absolute_path)
            self.assertTrue(os.path.exists(absolute_path))
            generated_from_fs = Image(absolute_path)
            self.assertEqual(out_image.width, generated_from_fs.width)
            self.assertEqual(out_image.height, generated_from_fs.height)
        finally:
            os.remove(absolute_path)
    def test_image_can_be_saved(self):
        image1 = Image(get_absolute_path('country/flags/bra.png'))
        image2 = Image(get_absolute_path('country/flags/can.png'))
        image3 = Image(get_absolute_path('country/flags/usa.png'))
        out_image = OutputImage(48 * 3, 48)
        out_image.add(image1, 0, 0)
        out_image.add(image2, 48, 0)
        out_image.add(image3, 96, 0)

        path = 'country/flags/sprite.png'
        absolute_path = os.path.join(settings.MEDIA_ROOT, path)
        try:
            out_image.save(absolute_path)
            self.assertTrue(os.path.exists(absolute_path))
            generated_from_fs = Image(absolute_path)
            self.assertEqual(out_image.width, generated_from_fs.width)
            self.assertEqual(out_image.height, generated_from_fs.height)
        finally:
            os.remove(absolute_path)
Example #3
0
 def generate(self):
     output = OutputImage(self.width, self.height)
     for name, image in self.images:
         pos = self.packing.get_image_position(image)
         output.add(image, pos.x, pos.y)
     return output
 def generate(self):
     output = OutputImage(self.width, self.height)
     for name, image in self.images:
         pos = self.packing.get_image_position(image)
         output.add(image, pos.x, pos.y)
     return output