1
I am trying to color a bar using python’s PIL package. This is the original bar:
I would like to color the entire inner part with just one color. I tried to use the floodfill
for that reason:
from PIL import Image, ImageDraw
im = Image.open('progress.jpeg')
width, height = im.size
center = (int(0.5*width), int(0.33* height))
yellow = (255, 255, 0, 255)
ImageDraw.floodfill(im, xy=center, value=yellow)
im.save('result.png')
And I got the following result:
Initially, I imagined that the floodfill
color all pixels that are between the specified width and height in the argument xy
. As I took 1/3 of the height and half of the greeting, he painted yellow the inner area from left to right, from half. However, if I use 100% width, the program does not color anything. So obviously my interpretation is wrong.
How does floodfill work? How can I color the internal bar completely?