How to use Pillow to create a swirl effect on an image?
Dec 26, 2025
Leave a message
Hey there, fellow image enthusiasts and pillow lovers! As a proud pillow supplier, I'm stoked to share with you a super cool way to jazz up your images using the amazing Pillow library in Python. And yeah, while we're at it, I'll also throw in some info about our top - notch pillows.
What's the Pillow Library?
First things first, let me give you a quick lowdown on the Pillow library. It's an open - source Python Imaging Library that's a real game - changer when it comes to image manipulation. Whether you're a newbie or a pro in the world of coding and image editing, Pillow makes it easy to do all sorts of cool stuff with your pictures. You can resize, crop, add filters, and in our case, create a super trippy swirl effect!
Why a Swirl Effect?
The swirl effect can take an ordinary image and turn it into a work of art. It adds a sense of movement and dynamism, making your photos stand out from the crowd. Maybe you're working on a graphic design project, creating some eye - catching social media posts, or just want to have some fun with your personal pictures. The swirl effect is a great way to add that extra oomph.
Getting Started with Pillow
Before we dive into creating the swirl effect, you need to have Pillow installed. If you haven't already, you can do it using pip. Just open up your terminal and type in:
pip install pillow
Once it's installed, you're ready to roll!
Let's Code the Swirl Effect
Here's a step - by - step guide on how to use Pillow to create a swirl effect on an image.
from PIL import Image, ImageFilter
def create_swirl_effect(image_path, output_path, degree=80, radius=100):
# Open the image
img = Image.open(image_path)
# Create a swirl effect
width, height = img.size
cx, cy = width // 2, height // 2
img = img.transform(img.size, Image.SWIRL, (cx, cy, radius, degree))
# Save the modified image
img.save(output_path)
# Example usage
image_path = 'your_image.jpg'
output_path = 'swirled_image.jpg'
create_swirl_effect(image_path, output_path)
In this code:
- We first import the necessary modules from the Pillow library:
Imagefor opening and saving the image, andImageFilterwhich isn't directly used for the swirl but is a handy addition for other filters. - The
create_swirl_effectfunction takes in the path of the original image, the path where you want to save the modified image, the degree of the swirl, and the radius of the area affected by the swirl. - We open the image using
Image.open(). - Then, we calculate the center of the image using the width and height. The
transformmethod with theImage.SWIRLmode is used to create the swirl effect. - Finally, we save the modified image to the specified output path.
Tweaking the Swirl Effect
You can play around with the degree and radius parameters to get different swirl effects. A higher degree will make the swirl more intense, while a larger radius will make the affected area bigger.
# A more intense swirl
create_swirl_effect(image_path, 'intense_swirl.jpg', degree = 120, radius = 150)
# A milder swirl with a smaller area
create_swirl_effect(image_path, 'mild_swirl.jpg', degree = 40, radius = 50)
Our Awesome Pillows
Now, while you're having fun with image effects, I also want to tell you about our incredible pillows. We offer a wide range of high - quality pillows to suit every need.
One of our best - sellers is the Hotel High Quality 100% Polyester Fiber Pillow. It's super soft, hypoallergenic, and perfect for those who want a comfortable night's sleep. The 100% polyester fiber filling provides great support and is easy to maintain.


If you're looking for something even plusher, check out the Premium Soft 100% Polyester Hotel Hollow Fiber Filled Bed Pillow. The hollow fiber filling gives it an extra bounce and makes it feel like you're sleeping on a cloud.
And for the ultimate in luxury, we have the Hotel High Qualtiy White Goose Down Pillow. The white goose down filling is incredibly soft and provides excellent insulation, keeping you warm in the winter and cool in the summer.
Contact Us for Purchasing
If you're interested in our pillows or have any questions, don't hesitate to reach out. We're always here to talk about our products and help you find the perfect pillow for your needs. Whether you're a hotel looking to upgrade your bedding or an individual in search of a better night's sleep, we've got you covered.
References
- Pillow official documentation
- Python official documentation
