Heading image

Prerequisites

  1. An image that is 1000x600 pixels.
  2. Some demo icons 100x100 pixels.
  3. Familiarity with [Pipenv]. See here for my post on Pipenv.
  4. Familiarity with JupyterLab. See here for my post on JupyterLab.
  5. Open Sans Bold font installed to fonts/OpenSans-Bold.ttf.

Getting started

Let’s create the hello-img-layers directory and install Pillow.

Creating the notebook

Once on http://localhost:8888/lab, select to create a new Python 3 notebook from the launcher.

  1. Load the image in.
  2. Creating the destination image and adding the icon layers.
  3. Creating the text layer.
  4. Saving and displaying the destination image.

Loading in the image

This section simply loads the image in var base_img (assuming you are following the directory structure where the notebook is in the docs folder).

Creating the destination image and adding the icon layers

We create the destination layer here based on the base images width and height and paste that base image back in.

Creating the text layer

This layer will load our Open Sans font and draw that onto the image.

Saving and displaying the destination image

Finally, we will save and display our base image.

Outcome

Summary

Today’s post demonstrated how to use the Pillow package to add text and icons layers to an image programmatically.

Resources and further reading

  1. The ABCs of Pipenv for the minimum you will need.
  2. Hello, JupyterLab.
  3. Pillow image library

--

--

--

Senior Engineer @ UsabilityHub. Formerly Culture Amp.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How do DAOs work? Decentralized Workforces Behind the Scenes

Game Dev in Progress… Day 33

How To Connect Local Server To HTML using FLASK ?

DeveloPassion’s Newsletter — Flywheels

5 Strategic Tips For Servers To Attack Returners

I did it my way

S03E03 Stop to go faster

Free and Accessible SQL Courses

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Dennis O'Keeffe

Dennis O'Keeffe

Senior Engineer @ UsabilityHub. Formerly Culture Amp.

More from Medium

My First Programming Project: Text-based Hangman Game using Python

Today Let’s talk about Python environment setup and HTTP REST API using Flask.

Scrape Apple Store Reviews with Python

How to create a secure OTP service with twilio verify and python