मैं पीआईएल/तकिया के ImageDraw मॉड्यूल का उपयोग कर एक छवि पर मोटी आयत खींचने की कोशिश कर रहा हूं।क्या पीआईएल में आयताकार की चौड़ाई निर्दिष्ट करने का कोई तरीका है?
मैंने draw.rectangle([x1, y1, x2, y2], outline='yellow', width=3)
का उपयोग करने की कोशिश की लेकिन यह चौड़ाई पैरामीटर की तरह प्रतीत नहीं होता है।
मैं अनुकरण कर सकता हूं कि मैं लाइनों के समूह के साथ क्या करना चाहता हूं, लेकिन मैं सोच रहा था कि ऐसा करने का उचित तरीका है या नहीं।
'''
coordinates = [x1, y1, x2, y2]
(x1, y1)
*--------------
| |
| |
| |
| |
| |
| |
--------------*
(x2, y2)
'''
def draw_rectangle(drawing, coordinates, color='yellow', width=3):
#top
line_coordinates = [coordinates[0], coordinates[1], coordinates[2], coordinates[1]]
drawing.line(line_coordinates, fill=color, width=width)
#left
line_coordinates = [coordinates[0], coordinates[1], coordinates[0], coordinates[3]]
drawing.line(line_coordinates, fill=color, width=width)
#right
line_coordinates = [coordinates[2], coordinates[1], coordinates[2], coordinates[3]]
drawing.line(line_coordinates, fill=color, width=width)
#bottom
line_coordinates = [coordinates[0], coordinates[3], coordinates[2], coordinates[3]]
drawing.line(line_coordinates, fill=color, width=width)