Esempio n. 1
0
def test_create(input_data, n_colours):
    p = palette.Palette(input_data)
    if isinstance(n_colours, tuple):
        # JPEG gets 80 colours in Python 2.7.9 and 3.4,
        # 82 in Python 2.7.12 and 3.5, 3.6...
        assert len(p) in n_colours
        assert len([c for c in p]) in n_colours
    else:
        assert len(p) == n_colours
        assert len([c for c in p]) == n_colours
Esempio n. 2
0
def test_create_bayer0():
    n_colours = 16
    p = palette.Palette(scene_undithered())
    if isinstance(n_colours, tuple):
        # JPEG gets 80 colours in Python 2.7.9 and 3.4,
        # 82 in Python 2.7.12 and 3.5, 3.6...
        assert len(p) in n_colours
        assert len([c for c in p]) in n_colours
    else:
        assert len(p) == n_colours
        assert len([c for c in p]) == n_colours
Esempio n. 3
0
def test_create_jpg(test_jpeg):
    n_colours = (80, 82)
    p = palette.Palette(test_jpeg.convert("P"))
    if isinstance(n_colours, tuple):
        # JPEG gets 80 colours in Python 2.7.9 and 3.4,
        # 82 in Python 2.7.12 and 3.5, 3.6...
        assert len(p) in n_colours
        assert len([c for c in p]) in n_colours
    else:
        assert len(p) == n_colours
        assert len([c for c in p]) == n_colours
    input(
        "please inform the resolution multiplier (default is 53x53, recommended is multiplier is 2.)\n"
    ))

#size of the picture drawn. larger pictures are very slow to draw.
size = (math.floor(53 * resolutionMultiplier),
        math.floor(53 * resolutionMultiplier))

unprosPic = Image.open(
    input("Please inform the name of the file (CaSe SENSitive!)\n"))

pic = unprosPic.convert("RGB").resize(size, Image.ANTIALIAS)
if dithering:

    pic = ordered.yliluoma.yliluomas_1_ordered_dithering(
        pic, palette.Palette(hexPalette), order=ditheringOrder).convert("RGB")

keyPic = []

for x in range(0, math.floor(53 * resolutionMultiplier)):
    keyPic.insert(x, [])
    for y in range(0, math.floor(53 * resolutionMultiplier)):
        mostSimilar = getMostSimilar(pic.getpixel((x, y)), colors)
        if not dithering:
            pic.putpixel((x, y), colors[mostSimilar[1]][2])
        keyPic[x].insert(y, mostSimilar[1])

pic.save("outpic.jpeg", "JPEG")
input(
    "IMAGE PROCESSING COMPLETE. DUMPING MODIFIED PICTURE TO 'outpic.jpeg'. SWITCH TO A HAT IN TIME'S WINDOW and PRESS 'a' TO START (WARNING! SCREEN MUST BE FULLSCREEN!)PRESS 's' AT ANY TIME TO ABORT THE OPERATION."
)
Esempio n. 5
0
def test_create_fails_4(test_jpeg):
    with pytest.raises(PaletteCouldNotBeCreatedError):
        p = palette.Palette(scene())
Esempio n. 6
0
def test_create_fails_3(test_jpeg):
    with pytest.raises(PaletteCouldNotBeCreatedError):
        p = palette.Palette(test_jpeg.convert("L"))
Esempio n. 7
0
def test_create_fails_1(test_png):
    with pytest.raises(PaletteCouldNotBeCreatedError):
        p = palette.Palette(test_png)
Esempio n. 8
0
def test_create_fails(input_data, n_colours):
    with pytest.raises(PaletteCouldNotBeCreatedError):
        p = palette.Palette(input_data)