Created
March 16, 2020 05:36
-
-
Save namieluss/a440061734075d929f0c6b9f6bd919c7 to your computer and use it in GitHub Desktop.
Add Borders to Images using Python Pillow
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import Image, ImageOps | |
# open image | |
img = Image.open("test_image.jpg") | |
# border color | |
color = "green" | |
# top, right, bottom, left | |
border = (20, 10, 20, 10) | |
new_img = ImageOps.expand(img, border=border, fill=color) | |
# save new image | |
new_img.save("test_image_result.jpg") | |
# show new bordered image in preview | |
new_img.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@blissdismissed Are you running the original code, or the code I shared recently? Can you share your full traceback?