Created
May 10, 2015 17:20
-
-
Save imerr/b06dabca6d7891d69130 to your computer and use it in GitHub Desktop.
tiny image compression test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import Image | |
import random | |
import pylzma | |
for i in xrange(1000): | |
print i | |
img = Image.new("RGB", (16, 12)) | |
data = img.load() | |
for x in range(16): | |
for y in range(12): | |
data[x,y] = (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)) | |
img.save("bmp/{}.bmp".format(i)) | |
img.save("gif/{}.gif".format(i)) | |
img.save("jpg/{}.jpg".format(i)) | |
img.save("png24/{}.png".format(i)) | |
img.convert('P', palette=Image.ADAPTIVE).save("png8/{}.png".format(i)) | |
with open("lzma/{}.xz".format(i), "wb") as f: | |
f.write(pylzma.compress(img.tobytes())) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment