-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
43 lines (33 loc) · 1.16 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from typing import List
import unittest
import pyqoi as pqoi
import numpy as np
from PIL import Image
class BasicTest(unittest.TestCase):
# def test_basic_encode_and_decode(self):
# f = Image.open("./qoi_test_images/dice.png")
# data: List[str] = [item for t in list(f.getdata()) for item in t]
# out_len = len(data)
# desc = pqoi.QoiHeader(
# width=f.width,
# height=f.height,
# channels=len(f.getbands()),
# colorspace=f.getexif().get("ColorSpace", 0),
# )
# encoded,out_len = pqoi.encode(data, desc, out_len)
# decoded = pqoi.decode(encoded,len(encoded),desc)
# f.close()
def test_file_conversion(self):
f = Image.open("./qoi_test_images/dice.png")
data: bytes = f.tobytes()
out_len = len(data)
desc = pqoi.QoiHeader(
width=f.width,
height=f.height,
channels=len(f.getbands()),
colorspace=f.getexif().get("ColorSpace", 0),
)
pqoi.write('./test.qoi',data,desc,out_len)
f.close()
if __name__ == "__main__":
unittest.main(verbosity=2)