tessl install tessl/pypi-imutils@0.5.0A series of convenience functions to make basic image processing functions such as translation, rotation, resizing, skeletonization, displaying Matplotlib images, sorting contours, detecting edges, and much more easier with OpenCV and both Python 2.7 and Python 3.
Agent Success
Agent success rate when using this tile
91%
Improvement
Agent success rate improvement when using this tile compared to baseline
1.34x
Baseline
Agent success rate without this tile
68%
Build a Python program that overlays multi-line text captions onto images. The system should handle text with line breaks and provide both regular and centered text placement options.
Your program should accept:
\n)The program should:
\n charactersCreate a Python module that provides a function with the following signature:
def add_caption(input_path: str, output_path: str, text: str,
position: tuple, font_face: int, font_scale: float,
color: tuple, thickness: int = 1, mode: str = "regular") -> None:
"""
Adds a multi-line text caption to an image.
Args:
input_path: Path to the input image file
output_path: Path where the output image will be saved
text: Caption text (may contain \\n for line breaks)
position: (x, y) tuple for text position (used in regular mode)
font_face: OpenCV font face constant (e.g., cv2.FONT_HERSHEY_SIMPLEX)
font_scale: Font scale factor
color: RGB tuple for text color (e.g., (255, 255, 255))
thickness: Text thickness in pixels
mode: "regular" for positioned text, "centered" for centered text
"""
passGiven an image and single-line text "Hello World" with position (10, 30), the text should appear at coordinates (10, 30). @test
Given an image and multi-line text "Line 1\nLine 2\nLine 3" with position (10, 30), all three lines should be rendered with proper spacing starting at (10, 30). @test
Given an image and text "Centered\nCaption" with mode="centered", the text block should be positioned in the center of the image both horizontally and vertically. @test
Provides image processing convenience functions including multi-line text rendering.
Provides core image processing capabilities for reading, writing, and manipulating images.
Provides array operations for image data manipulation.