Skip to content

Instantly share code, notes, and snippets.

@thejsj
Last active February 4, 2019 19:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thejsj/e5f9ed0a4d259ac3c8d1678a9c65337a to your computer and use it in GitHub Desktop.
Save thejsj/e5f9ed0a4d259ac3c8d1678a9c65337a to your computer and use it in GitHub Desktop.
Pillow Test
virtualenv -p python3 venv # Delete Later with `rm -rf venv`
source venv/bin/activate
pip install Pillow
python -c "from PIL import Image; import urllib.request; urllib.request.urlretrieve('https://images.unsplash.com/photo-1518791841217-8f162f1e1131', '/tmp/cat.jpg'); im = Image.open('/tmp/cat.jpg'); im.thumbnail((256, 256)); im.save('/tmp/cat-resize.jpg', 'JPEG'); im = Image.open('/tmp/cat-resize.jpg'); print(im.format, im.size, im.mode)"
python --version # 2.x
pip install Pillow
python -c "from PIL import Image; import urllib; urllib.urlretrieve('https://images.unsplash.com/photo-1518791841217-8f162f1e1131', '/tmp/cat.jpg'); im = Image.open('/tmp/cat.jpg'); im.thumbnail((256, 256)); im.save('/tmp/cat-resize.jpg', 'JPEG'); im = Image.open('/tmp/cat-resize.jpg'); print(im.format, im.size, im.mode)"
python --version # 3.x
pip install Pillow
python -c "from PIL import Image; import urllib.request; urllib.request.urlretrieve('https://images.unsplash.com/photo-1518791841217-8f162f1e1131', '/tmp/cat.jpg'); im = Image.open('/tmp/cat.jpg'); im.thumbnail((256, 256)); im.save('/tmp/cat-resize.jpg', 'JPEG'); im = Image.open('/tmp/cat-resize.jpg'); print(im.format, im.size, im.mode)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment