[Code Snippet] Adding borders to an image using Python

After a long time… I’m back!

Now, I going to show you how use python to add borders to an image.


import Image
import ImageOps

if __name__ == '__main__':
    image_name="terminator.jpg"
    new_image_name="terminator_with_border.jpg"
    image_file = Image.open(image_name)
    new_image_file = ImageOps.expand(image_file, border=10, fill='red')
    new_image_file.save(new_image_name)

Input image

Input image

Output image

Output image

That’s all folks!


Warning: Missing argument 1 for cwppos_show_review(), called in /home/rodrigolira/blog.rodrigolira.net/wp-content/themes/flat/content-single.php on line 29 and defined in /home/rodrigolira/blog.rodrigolira.net/wp-content/plugins/wp-product-review/includes/legacy.php on line 18