def test_optimize(self): renderer = PngRenderer(png8=False, optimize=2) contents = renderer.render(image=self.image) self.assertEqual(intmd5(contents), 227024021824580215543073313661866089265) # Default is PNG8=False and optimize=2 renderer = PngRenderer() contents = renderer.render(image=self.image) self.assertEqual(intmd5(contents), 89446660811628514001822794642426893173)
def test_simple(self): renderer = JpegRenderer() # Black 1×1 image image = VImageAdapter.new_rgba(width=1, height=1, ink=rgba(r=0, g=0, b=0, a=255)) black = renderer.render(image=image) black_md5 = intmd5(black) # Transparent 1×1 image image = VImageAdapter.new_rgba(width=1, height=1, ink=rgba(r=0, g=0, b=0, a=0)) transparent = renderer.render(image=image) self.assertEqual(intmd5(transparent), black_md5)
def test_save(self): # We must create this on disk self.storage = MbtilesStorage.create(renderer=self.renderer, filename=self.tempfile.name, metadata=self.metadata) # Transparent 1×1 image image = VImage.new_rgba(width=1, height=1, ink=rgba(r=0, g=0, b=0, a=0)) # Save it twice, assuming that MBTiles will deduplicate self.storage.save(x=0, y=1, z=2, image=image) self.storage.save(x=1, y=0, z=2, image=image) self.storage.waitall() # Assert that things were saved properly self.assertEqual( [(z, x, y, intmd5(data)) for z, x, y, data in self.storage.mbtiles.all()], [ (2, 0, 1, 89446660811628514001822794642426893173), (2, 1, 0, 89446660811628514001822794642426893173), ] ) # Close the existing database. self.storage.mbtiles.close() # Re-open the created file storage = MbtilesStorage(renderer=self.renderer, filename=self.tempfile.name) # Read out of the backend self.assertEqual( [(z, x, y, intmd5(data)) for z, x, y, data in storage.mbtiles.all()], [ (2, 0, 1, 89446660811628514001822794642426893173), (2, 1, 0, 89446660811628514001822794642426893173), ] )
def test_save_border(self): # Western hemisphere is border self.storage.save_border(x=0, y=0, z=1) self.storage.save_border(x=0, y=1, z=1) # Assert that things were saved properly self.assertEqual( [(z, x, y, intmd5(data)) for z, x, y, data in self.storage.mbtiles.all()], [ (1, 0, 0, 182760986852492185208562855341207287999), (1, 0, 1, 182760986852492185208562855341207287999), ])
def test_save_border(self): # Western hemisphere is border self.storage.save_border(x=0, y=0, z=1) self.storage.save_border(x=0, y=1, z=1) # Assert that things were saved properly self.assertEqual( [(z, x, y, intmd5(data)) for z, x, y, data in self.storage.mbtiles.all()], [ (1, 0, 0, 182760986852492185208562855341207287999), (1, 0, 1, 182760986852492185208562855341207287999), ] )
def test_png8_optimize(self): renderer = PngRenderer(png8=True, optimize=2) contents = renderer.render(image=self.image) self.assertEqual(intmd5(contents), 151059771043192964835020617733646275057)
def test_interlace(self): renderer = PngRenderer(interlace=1, png8=False, optimize=False) contents = renderer.render(image=self.image) self.assertEqual(intmd5(contents), 197686704564132731296723533976357306757)
def test_compression(self): renderer = PngRenderer(compression=1, png8=False, optimize=False) contents = renderer.render(image=self.image) self.assertEqual(intmd5(contents), 227024021824580215543073313661866089265)
def test_simple(self): renderer = PngRenderer(png8=False, optimize=False) contents = renderer.render(image=self.image) self.assertEqual(intmd5(contents), 89446660811628514001822794642426893173)
def test_png8_optimize(self): renderer = PngRenderer(png8=True, optimize=2) contents = renderer.render(image=self.image) self.assertEqual(intmd5(contents), 106831624867432276165545554861383631224)