Skip to content

Instantly share code, notes, and snippets.

@phoet
Forked from mat/artifacts.py
Created January 19, 2016 13:00
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save phoet/6c2cfbff0809af451109 to your computer and use it in GitHub Desktop.
Pillow PNG artifacts
#!/usr/bin/python
# -*- coding: utf-8 -*-
# This script reproduces the issue with artifacts when
# handling (semi)transparent PNG files:
# https://github.com/python-pillow/Pillow/issues/1449
# Version used:
#
# Python 2.7.10 (default, Jul 14 2015, 19:46:27)
# [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
#
# PILLOW_VERSION: 3.0.0
#
#
# Setup:
# pip install pillow
#
from PIL import Image
from PIL import PILLOW_VERSION
def main():
im = Image.open("original.png")
# <PIL.PngImagePlugin.PngImageFile image mode=LA size=1820x672 at 0x10855F550>
im.thumbnail((259, 96))
im.save("thumbnail.png")
print "PILLOW_VERSION: ", PILLOW_VERSION
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment