Python 3 Script to Add Colorful Border Frames to Image Files Using Pillow Library Full Tutorial For Beginners

Python 3 Script to Add Colorful Border Frames to Image Files Using Pillow Library Full Tutorial For Beginners

 

 

 

Welcome folks today in this post we will be writing a python script in which we will be adding colorful border frames to image files using pillow library. All the full source code of the application is shown below.

 

 

 

Get Started

 

 

 

In order to get started you need to install the following library into your python project using the pip command

 

pip install pillow

 

After installing this library you need to create an app.py file and copy paste the following code

 

app.py

 

from PIL import Image, ImageOps
ImageOps.expand(Image.open('profile.jpg'),border=20,fill="#f00").save('imaged-with-border.png')

 

 

Here in this two lines of python code we are importing the pillow library and then we are opening the input image and then we are adding the border of any color and size.These two parameters you can control i.e. the color of the border you can pass hex code also and the size of the border which is 20 and then we are saving the output image by using the save method

See also  Python 3 Tkinter Script to Open Multiple New Windows or Tabs on Button Click Using Functions and Classes in GUI Desktop App Full Project For Beginners

 

And if you run this python script at the command prompt by typing the below command

 

python app.py

 

 

 

 

So as you can see the image is having the colorful border frame of red color attached to it

 

Leave a Reply