# cv2.putText with new lines
## Tested against Windows 10 / Python 3.11 / Anaconda
### pip install cv2multilinewrite
Code from: https://stackoverflow.com/a/73471951/15096247
![](https://i.stack.imgur.com/2egap.png)
```python
import cv2
import numpy as np
image = 200 * np.ones((550, 410, 3), dtype=np.uint8)
image = add_text_to_image(
image,
"New line\nDouble new line\n\nLine too longggggggggggggggggggggg",
top_left_xy=(0, 10),
)
image = add_text_to_image(
image,
"Different font scale",
font_scale=0.5,
font_color_rgb=(0, 255, 0),
top_left_xy=(0, 150),
)
image = add_text_to_image(
image,
"New line with bg\nDouble new line\n\nLine too longggggggggggggggggggggg",
bg_color_rgb=(255, 255, 255),
font_color_rgb=(255, 0, 0),
top_left_xy=(0, 200),
)
image = add_text_to_image(
image,
"Different line specing,\noutline and font face",
font_color_rgb=(0, 255, 255),
outline_color_rgb=(0, 0, 0),
top_left_xy=(0, 350),
line_spacing=1.5,
font_face=cv2.FONT_HERSHEY_SCRIPT_SIMPLEX,
)
import matplotlib.pyplot as plt
plt.imshow(image)
plt.show()
```
Raw data
{
"_id": null,
"home_page": "https://github.com/hansalemaos/cv2multilinewrite",
"name": "cv2multilinewrite",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "cv2,putText",
"author": "Johannes Fischer",
"author_email": "aulasparticularesdealemaosp@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/23/22/77503bbe3c4264400ab13d6bc1f92e8a0e759aa60956d792a2efc18aa9e8/cv2multilinewrite-0.10.tar.gz",
"platform": null,
"description": "\r\n# cv2.putText with new lines \r\n\r\n## Tested against Windows 10 / Python 3.11 / Anaconda\r\n\r\n### pip install cv2multilinewrite\r\n\r\nCode from: https://stackoverflow.com/a/73471951/15096247\r\n\r\n\r\n![](https://i.stack.imgur.com/2egap.png)\r\n\r\n```python\r\nimport cv2\r\nimport numpy as np\r\n\r\nimage = 200 * np.ones((550, 410, 3), dtype=np.uint8)\r\n\r\nimage = add_text_to_image(\r\n image,\r\n \"New line\\nDouble new line\\n\\nLine too longggggggggggggggggggggg\",\r\n top_left_xy=(0, 10),\r\n)\r\nimage = add_text_to_image(\r\n image,\r\n \"Different font scale\",\r\n font_scale=0.5,\r\n font_color_rgb=(0, 255, 0),\r\n top_left_xy=(0, 150),\r\n)\r\nimage = add_text_to_image(\r\n image,\r\n \"New line with bg\\nDouble new line\\n\\nLine too longggggggggggggggggggggg\",\r\n bg_color_rgb=(255, 255, 255),\r\n font_color_rgb=(255, 0, 0),\r\n top_left_xy=(0, 200),\r\n)\r\nimage = add_text_to_image(\r\n image,\r\n \"Different line specing,\\noutline and font face\",\r\n font_color_rgb=(0, 255, 255),\r\n outline_color_rgb=(0, 0, 0),\r\n top_left_xy=(0, 350),\r\n line_spacing=1.5,\r\n font_face=cv2.FONT_HERSHEY_SCRIPT_SIMPLEX,\r\n)\r\nimport matplotlib.pyplot as plt\r\n\r\nplt.imshow(image)\r\nplt.show()\r\n```\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "cv2.putText with new lines",
"version": "0.10",
"project_urls": {
"Homepage": "https://github.com/hansalemaos/cv2multilinewrite"
},
"split_keywords": [
"cv2",
"puttext"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "1fd789f7c3da5cd68714039d179d2deab0ad33d7332e44b319d9add9a9259969",
"md5": "664a59f141a44d2579709b9605abca1b",
"sha256": "882b88759d025d22f82b09268b5bdef0c8ee1246c76842ba73adc9c6b9b03e59"
},
"downloads": -1,
"filename": "cv2multilinewrite-0.10-py3-none-any.whl",
"has_sig": false,
"md5_digest": "664a59f141a44d2579709b9605abca1b",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 55812,
"upload_time": "2023-09-21T02:59:12",
"upload_time_iso_8601": "2023-09-21T02:59:12.756452Z",
"url": "https://files.pythonhosted.org/packages/1f/d7/89f7c3da5cd68714039d179d2deab0ad33d7332e44b319d9add9a9259969/cv2multilinewrite-0.10-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "232277503bbe3c4264400ab13d6bc1f92e8a0e759aa60956d792a2efc18aa9e8",
"md5": "d434cca42f02d06feda841ae06297b8e",
"sha256": "a94863d08311b1c2e6c0f245921cf0870f85ae48e5f31cdd7b799c8728e740d3"
},
"downloads": -1,
"filename": "cv2multilinewrite-0.10.tar.gz",
"has_sig": false,
"md5_digest": "d434cca42f02d06feda841ae06297b8e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 55321,
"upload_time": "2023-09-21T02:59:14",
"upload_time_iso_8601": "2023-09-21T02:59:14.778529Z",
"url": "https://files.pythonhosted.org/packages/23/22/77503bbe3c4264400ab13d6bc1f92e8a0e759aa60956d792a2efc18aa9e8/cv2multilinewrite-0.10.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-09-21 02:59:14",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "hansalemaos",
"github_project": "cv2multilinewrite",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "cv2multilinewrite"
}