How to use Pillow to create a starburst effect on an image?

Dec 16, 2025

Leave a message

Hey there! As a pillow supplier, I'm not only into providing top - notch pillows but also have a soft spot for image - editing fun with Pillow, the Python library. Today, I'm gonna walk you through how to use Pillow to create a starburst effect on an image.

First off, what's Pillow? Pillow is a powerful and user - friendly Python library for image processing. It allows you to open, manipulate, and save different image file formats. And creating a starburst effect on an image can make your pictures look more dynamic, eye - catching, and artistic.

Step 1: Install Pillow

If you haven't installed Pillow yet, it's super easy. Open your command prompt or terminal and run the following command:

pip install pillow

This will download and install the latest version of Pillow on your system.

Step 2: Import the Necessary Libraries

Once Pillow is installed, you need to import it in your Python script. Here's how you do it:

from PIL import Image, ImageDraw, ImageFilter
import math

We're importing Image to open and manipulate the image, ImageDraw to draw shapes on the image, ImageFilter to apply filters, and math because we'll need some mathematical operations for the starburst effect.

Step 3: Open the Image

Let's say you have an image named your_image.jpg in the same directory as your Python script. You can open it like this:

image = Image.open('your_image.jpg')
width, height = image.size

We're also getting the width and height of the image, which will be useful later.

Step 4: Create the Starburst Effect

The starburst effect is all about creating lines that radiate from a central point. Here's the code to achieve that:

Hotel High Quality 100% Polyester Fiber Pillow factoryHotel High Quality 100% Polyester Fiber Pillow manufacturers

draw = ImageDraw.Draw(image)
center_x = width // 2
center_y = height // 2
num_lines = 36
angle_step = 360 / num_lines

for i in range(num_lines):
    angle = math.radians(i * angle_step)
    end_x = center_x + math.cos(angle) * min(width, height)
    end_y = center_y + math.sin(angle) * min(width, height)
    draw.line((center_x, center_y, end_x, end_y), fill=(255, 255, 0), width = 2)

In this code, we first calculate the center of the image. Then we decide how many lines we want for the starburst (in this case, 36). We loop through each line, calculate the angle for that line, and then find the end point of the line using trigonometric functions. Finally, we draw the line on the image.

Step 5: Apply a Blur Filter (Optional)

To make the starburst effect look more natural, you can apply a blur filter to the image:

image = image.filter(ImageFilter.GaussianBlur(radius = 2))

The radius parameter controls how much blur is applied. You can adjust it according to your preference.

Step 6: Save the Image

Once you're happy with the starburst effect, you can save the image:

image.save('starburst_image.jpg')

Now, while you're having fun with image editing using Pillow, don't forget that we're also a pillow supplier. We offer a wide range of high - quality pillows for your comfort. Check out our Premium Soft 100% Polyester Hotel Hollow Fiber Filled Bed Pillow, which is perfect for a good night's sleep. If you prefer a more luxurious option, our Hotel High Qualtiy White Goose Down Pillow is a great choice. And for those who want a budget - friendly yet high - quality pillow, our Hotel High Quality 100% Polyester Fiber Pillow won't disappoint.

If you're interested in purchasing our pillows in bulk, we're more than happy to have a chat with you. Whether you're a hotelier looking to upgrade your bedding or an individual who just wants the best pillow for their home, we can work out a great deal for you. Just reach out to us, and we'll get the ball rolling on your pillow procurement.

References

  • Pillow official documentation
  • Python official documentation for math library

So there you have it! You now know how to use Pillow to create a starburst effect on an image. Have fun experimenting, and don't hesitate to contact us for all your pillow needs.

Send Inquiry