Skip to content

Instantly share code, notes, and snippets.

@thejsj
Last active February 5, 2019 06:33
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/f79b18e8a0dedadbee34c7ff72037d73 to your computer and use it in GitHub Desktop.
Save thejsj/f79b18e8a0dedadbee34c7ff72037d73 to your computer and use it in GitHub Desktop.
Image Testing (Pillow + Basilica)

How to run this

If you have virtualenv

curl https://gist.github.com/thejsj/f79b18e8a0dedadbee34c7ff72037d73/raw/d5908867a8901c81848b6d86b316bb10d5ff117a/basilica_images-with-virtualenv.bash | bash

If you have Python 2.7 (Most probable)

curl https://gist.github.com/thejsj/f79b18e8a0dedadbee34c7ff72037d73/raw/e398a56528c31b35b58a567a3c6f431d8acd57b2/basilica-images-2.7.bash | bash

If you have Python 3.6 (Most probable)

curl https://gist.github.com/thejsj/f79b18e8a0dedadbee34c7ff72037d73/raw/e398a56528c31b35b58a567a3c6f431d8acd57b2/basilica-images-3.6.bash | bash
if [ $(pip --version | grep -ic "3") -eq 1 ]; then echo "WRONG PIP VERSION"; fi
if [ $(python --version | grep -ic "3") -eq 1 ]; then echo "WRONG PYTHON VERSION"; fi
pip install Pillow request
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)"
pip install git+git://github.com/mlucy/basilica-client.git@6bead666075bf9f29730d7eb28366016dc1bfad2#subdirectory=basilica
python -c "import basilica; import urllib; urllib.urlretrieve('https://images.unsplash.com/photo-1518791841217-8f162f1e1131', '/tmp/cat.jpg'); c = basilica.Connection('SLOW_DEMO_KEY'); c.embed_image_file('/tmp/cat.jpg');"
python -c "import basilica; import urllib; urllib.urlretrieve('https://www.hondenpensionplukkie.nl/wp-content/uploads/2016/09/Cat-PNG.png', '/tmp/cat.png'); c = basilica.Connection('SLOW_DEMO_KEY'); c.embed_image_file('/tmp/cat.png');"
pip uninstall -y basilica
pip uninstall -y Pillow request # If you didn't have it installed
if [ $(pip --version | grep -ic "2.7") -eq 1 ]; then echo "WRONG PIP VERSION"; fi
if [ $(python --version | grep -ic "2.7") -eq 1 ]; then echo "WRONG PYTHON VERSION"; fi
pip install Pillow request
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)"
pip install git+git://github.com/mlucy/basilica-client.git@6bead666075bf9f29730d7eb28366016dc1bfad2#subdirectory=basilica
python -c "import basilica; import urllib.request; urllib.request.urlretrieve('https://images.unsplash.com/photo-1518791841217-8f162f1e1131', '/tmp/cat.jpg'); c = basilica.Connection('SLOW_DEMO_KEY'); c.embed_image_file('/tmp/cat.jpg');"
python -c "import basilica; import urllib.request; urllib.request.urlretrieve('https://www.hondenpensionplukkie.nl/wp-content/uploads/2016/09/Cat-PNG.png', '/tmp/cat.png'); c = basilica.Connection('SLOW_DEMO_KEY'); c.embed_image_file('/tmp/cat.png');"
pip uninstall -y basilica
pip uninstall -y Pillow request # If you didn't have it installed
virtualenv -p python3 venv # Delete Later with `rm -rf venv`
source venv/bin/activate
pip install Pillow request
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)"
pip install git+git://github.com/mlucy/basilica-client.git@6bead666075bf9f29730d7eb28366016dc1bfad2#subdirectory=basilica
python -c "import basilica; import urllib.request; urllib.request.urlretrieve('https://images.unsplash.com/photo-1518791841217-8f162f1e1131', '/tmp/cat.jpg'); c = basilica.Connection('SLOW_DEMO_KEY'); c.embed_image_file('/tmp/cat.jpg');"
python -c "import basilica; import urllib.request; urllib.request.urlretrieve('https://www.hondenpensionplukkie.nl/wp-content/uploads/2016/09/Cat-PNG.png', '/tmp/cat.png'); c = basilica.Connection('SLOW_DEMO_KEY'); c.embed_image_file('/tmp/cat.png');"
rm -rf venv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment