Image outputting v0.1

I have not tried it :-)
master
LEdoian 3 years ago
parent bf4ab225f2
commit 3383699269

@ -51,8 +51,29 @@ class Picture:
assert result.h == ht assert result.h == ht
return result return result
def _to_pil(self):
# Create int iterable
# TODO: If this is slow, we should use a generator.
seq = []
for line in self.pixels:
for pix in line:
seq.extend(pix)
def show(self): ... # bytes…
b = bytes(seq)
# PIL image
from PIL import Image
img = Image.frombytes('RGB', (self.w, self.h), b)
return img
def show(self):
img = self._to_pil()
img.show()
def save(self, filename):
img = self._to_pil()
img.save(filename)
class Interpolator: class Interpolator:
def interpolate(self, picture, new_h, new_w): def interpolate(self, picture, new_h, new_w):

Loading…
Cancel
Save