Search code examples
pythontkinterpython-imaging-librarystreamlit

How to add a box inside the image using python


I have a code which convert the image into color sketch in that i have added a text(water mark) due to the dark background the text is not properly visible so i need a box with white background so that text would be clearly visible

To display text in bottom right i have did some calculation using width and height

Thanks in Advance


Solution

  • Just use ImageDraw.rectangle() to draw a white rectangle before adding the text:

    final1.rectangle((x,y,width,height), fill="white")
    

    I think some folk call it an "underbox".