Ejemplo n.º 1
0
 def test_compressed_buffer(self):
     # because this is just a simple red background it compresses VERY well
     # from 12528 to 206 bytes.
     #
     # Of course, for real images it may not be worth compressing them at all.
     buffer = giraffe.image_to_buffer(self.image)
     compressed_buffer = giraffe.image_to_buffer(self.image, compress=True)
     compressed_size = len(compressed_buffer.getvalue())
     uncompressed_size = len(buffer.getvalue())
     print("normal: %s, compressed: %s"%(uncompressed_size, compressed_size))
     self.assertLess(compressed_size, uncompressed_size)
Ejemplo n.º 2
0
 def test_compressed_buffer(self):
     # because this is just a simple red background it compresses VERY well
     # from 12528 to 206 bytes.
     #
     # Of course, for real images it may not be worth compressing them at all.
     buffer = giraffe.image_to_buffer(self.image)
     compressed_buffer = giraffe.image_to_buffer(self.image, compress=True)
     compressed_size = len(compressed_buffer.getvalue())
     uncompressed_size = len(buffer.getvalue())
     print("normal: %s, compressed: %s" %
           (uncompressed_size, compressed_size))
     self.assertLess(compressed_size, uncompressed_size)
Ejemplo n.º 3
0
 def test_image_to_binary(self):
     buffer = giraffe.image_to_buffer(self.image)
     self.assertEqual(buffer.getvalue(), giraffe.image_to_binary(self.image))
Ejemplo n.º 4
0
 def test_buffer(self):
     buffer = giraffe.image_to_buffer(self.image)
     # a valid jpeg buffer should have JFIF in the first few bytes
     self.assertIn(b"JFIF", buffer.getvalue()[:100])
Ejemplo n.º 5
0
 def test_image_to_binary(self):
     buffer = giraffe.image_to_buffer(self.image)
     self.assertEqual(buffer.getvalue(),
                      giraffe.image_to_binary(self.image))
Ejemplo n.º 6
0
 def test_buffer(self):
     buffer = giraffe.image_to_buffer(self.image)
     # a valid jpeg buffer should have JFIF in the first few bytes
     self.assertIn(b"JFIF", buffer.getvalue()[:100])