2012-10-16 00:26:38 +04:00
|
|
|
from tester import *
|
|
|
|
|
|
|
|
from PIL import Image
|
|
|
|
|
|
|
|
def test_sanity():
|
|
|
|
|
|
|
|
im = lena()
|
|
|
|
|
|
|
|
im = im.quantize()
|
|
|
|
assert_image(im, "P", im.size)
|
|
|
|
|
|
|
|
im = lena()
|
|
|
|
im = im.quantize(palette=lena("P"))
|
|
|
|
assert_image(im, "P", im.size)
|
2013-07-01 02:42:19 +04:00
|
|
|
|
2013-03-11 23:33:04 +04:00
|
|
|
def test_octree_quantize():
|
|
|
|
im = lena()
|
|
|
|
|
|
|
|
im = im.quantize(100, Image.FASTOCTREE)
|
|
|
|
assert_image(im, "P", im.size)
|
|
|
|
|
2014-03-26 08:42:04 +04:00
|
|
|
assert len(im.getcolors()) == 100
|
|
|
|
|
|
|
|
def test_rgba_quantize():
|
|
|
|
im = lena('RGBA')
|
|
|
|
assert_no_exception(lambda: im.quantize())
|
|
|
|
assert_exception(Exception, lambda: im.quantize(method=0))
|