Let's develop code that adds a frame around a picture.
Download the image
0165_3_15_COLOR_TWEAK.png
and rename it toFLOWER.png
.Add the following code in a Python source file. Make sure to modify the code to specify in the input and output paths appropriately.
1 import Image, ImageOps 2 img = Image.open( "C:\\images\\FLOWER.png ") 3 img = ImageOps.expand(img, border=20, fill='black') 4 img = ImageOps.expand(img, border=40, fill='silver') 5 img = ImageOps.expand(img, border=2, fill='black') 6 img.save( "C:\\images\\PHOTOFRAME.png ") 7 img.show()
In this code snippet, three stacked borders are created. The innermost border layer is rendered with black color. This is intentionally chosen darker.
Next, there is a middle layer of border, rendered with a lighter color (silver color in this case). This is done by the code on line 4. It is thicker than the innermost border.
The outermost border is created by code on line 5. It is a very thin layer...