Read our blogs, tips and tutorials
Try our exercises or test your skills
Watch our tutorial videos or shorts
Take a self-paced course
Read our recent newsletters
License our courseware
Book expert consultancy
Buy our publications
Get help in using our site
431 attributed reviews in the last 3 years
Refreshingly small course sizes
Outstandingly good courseware
Whizzy online classrooms
Wise Owl trainers only (no freelancers)
Almost no cancellations
We have genuine integrity
We invoice after training
Review 30+ years of Wise Owl
View our top 100 clients
Search our website
We also send out useful tips in a monthly email newsletter ...
|
Calling Python code from within Excel, and the vast functionality it unlocks Part three of a five-part series of blogs |
|---|
|
Excel and Python are getting ever more intertwined: you can now use the PY function to write (and call) Python code from within an Excel worksheet
|
In this blog
This part of the blog shows how you can apply effects to images using the Python Pillow module:
To get this to work each image must be included in a single cell. Here's how to add an image like this:

Here we're inserting an image into a single cell from the available online pictures.
You can then adjust the row height and column width to change the size of this image:

The image was square, so we've made our row height and column width the same.
You can show an image just by getting a reference to it:

This will show a copy of the picture in another cell.
This uses the PIL image library module. Again, experienced Python programmers will be wondering where this is referenced - read the part of this blog on modules for the answer to this question.
If you're curious (and I hope you are) you could have a look to see what sort of thing this image is:

Get the type of the picture, and convert this to a string for display. It turns out this is a JpegImageFile in the PIL module!
Here's one simple example of how you could use Python to render images in black and white, not colour:

Here we're doing a simple conversion to greyscale, but the possibilities are almost endless!
The great thing about this is that you can now copy the Python code to another cell, to process another animail:

The same code is now leaching the colour out of a deer too.
Notice the way that I changed the names of the variables in my Python code to make them generic, so that the code would still make sense when I copied it to reference a different animal's picture.
| Parts of this blog |
|---|
|
Some other pages relevant to the above blogs include:
Kingsmoor House
Railway Street
GLOSSOP
SK13 2AA
Landmark Offices
99 Bishopsgate
LONDON
EC2M 3XD
Holiday Inn
25 Aytoun Street
MANCHESTER
M1 3AE
© Wise Owl Business Solutions Ltd 2025. All Rights Reserved.