Try using Pillow on iPython (Part 1)

Pillow work flow (1)

  1. Create an image with Image.new
  2. Use ImageDraw etc. to squeeze the image
  3. Save the image edited with Image.save

Illustration

sc-20150321.PNG

python


%pylab inline
from PIL import Image,ImageDraw,ImageFont

#Create an image
img = Image.new('RGB', (800,200),(255,255,255)) # 800*200 white background

#Edit image
draw = ImageDraw.Draw(img) 
draw.line((0, 0, 799, 199),fill='green') #Green straight line

pl_img = np.array(img) ; plt.imshow( pl_img ) #display

FONTPATH = '/usr/share/fonts/truetype/fonts-japanese-gothic.ttf'
font = ImageFont.truetype(FONTPATH, 24, encoding='utf-8')
draw.text((40,80),'Test test test test',font=font, fill='black') 

pl_img = np.array(img) ; plt.imshow( pl_img ) #display

#Save image
img.save('test_draw.png') 

I can say it myself, but it's not very interesting.

↓ I tried to raise the notebook here nbviewer.ipython.org/github/suto3/git-public/blob/master/python/notebook/Pillow-workflow01.ipynb

↓ Click here for the working environment Pillow environment construction --Virtual environment by virtualenv, interactive environment by iPython --Qiita

Try using Pillow on iPython (Part 2) --Qiita

Try Pillow on iPython (Part 3) --Qiita

Recommended Posts

Try using Pillow on iPython (Part 1)
Try using Pillow on iPython (Part 2)
Try using Pillow on iPython (Part 3)
Try using OpenCV on Windows
Try using SQLAlchemy + MySQL (Part 1)
Try using SQLAlchemy + MySQL (Part 2)
Try using ArUco on Raspberry Pi
Try using Bash on Windows 10 2 (TensorFlow installation)
Try using Tkinter
Try using docker-py
Try using cookiecutter
Try using PDFMiner
Try using geopandas
Try using Selenium
Try using scipy
Try using pandas.DataFrame
Try using django-swiftbrowser
Try using matplotlib
Try using tf.metrics
Try using PyODE
Graph analysis and visualization on IPython Notebook using Cytoscape / cyREST and py2cytoscape Part 1
Try using a QR code on a Raspberry Pi
Python: Try using the UI on Pythonista 3 on iPad
Try using the Python web framework Tornado Part 1
Make predictions using regression on actual data ~ part1
Try using the Python web framework Tornado Part 2
Visualize network data using Cytoscape from IPython Notebook Part 1
Try using virtualenv (virtualenvwrapper)
Try using E-Cell 4 on Windows 7 or Mac OS X
Try using the temperature sensor (LM75B) on the Raspberry Pi.
[Azure] Try using Azure Functions
I tried using Ipython
Try using virtualenv now
Try using W & B
Try using Django templates.html
[Kaggle] Try using LGBM
Try using Python's feedparser.
Try using Python's Tkinter
Try FEniCS on Windows!
Try Poerty on Windows
Try NeosVR on Linux
Notes on using Alembic
Try using Tweepy [Python2.7]
Try deepdream on Mac
Try using Pytorch's collate_fn
When using optparse with iPython
Try using PythonTex with Texpad.
Try normal Linux programming Part 7
[Python] Try using Tkinter's canvas
OpenPose on MacBook Pro Part 2
Try using Jupyter's Docker image
Try using scikit-learn (1) --K-means clustering
Try function optimization using Hyperopt
Try StyleGAN on Google Colaboratory
Make iPython available on OSGeo4W
Try using matplotlib with PyCharm
Try using Azure Logic Apps
Try using Kubernetes Client -Python-
[Kaggle] Try using xg boost
Try using the Twitter API
Try normal Linux programming Part 2