# Text effects for OpenCV
```python
$pip install a-cv2-text-effects
import os
from a_cv_imwrite_imread_plus import open_image_in_cv,save_cv_image
from a_cv2_text_effects import (
put_ttf_font_multiline_in_box_at_exact_center_location_with_exact_size,
put_ttf_font_multiline_at_exact_center_location_with_exact_size,
put_ttf_font_multiline_at_exact_location_with_exact_size,
put_ttf_font_multiline_in_box_at_exact_location_with_exact_size,
put_ttf_font_in_circle_at_exact_location_with_exact_size,
put_ttf_font_in_box_at_exact_location_with_exact_size,
put_ttf_font_at_exact_location_with_exact_size,
putTrueTypeText,
center_text_at_certain_size_at_a_specific_point,
center_of_text_at_certain_size_at_a_specific_point_with_boxes,
)
img = open_image_in_cv(
"https://raw.githubusercontent.com/hansalemaos/screenshots/main/merg6.png"
)
maxwidth = 150
maxheight = 150
(
imgresult1,
ptLowerLeftTextOriginX2,
ptLowerLeftTextOriginY2,
intFontFace2,
fltFontScale2,
intFontThickness2,
textSize2,
) = center_of_text_at_certain_size_at_a_specific_point_with_boxes(
img,
"Number 1",
maxwidth,
maxheight,
wheretoput=(200, 200),
color=(255, 255, 0),
add_thickness_each=10,
rectangle_border_size=5,
rectangle_border_colors=((244, 255, 0), (244, 0, 255)),
)
(
imgresult2,
ptLowerLeftTextOriginX,
ptLowerLeftTextOriginY,
intFontFace,
fltFontScale,
intFontThickness,
textSize,
) = center_text_at_certain_size_at_a_specific_point(
img,
"Number 2",
maxwidth,
maxheight,
wheretoput=(100, 100),
color=(255, 255, 0),
add_thickness_each=10,
)
imgresult3 = putTrueTypeText(
img=img,
text="Number 3",
org=(100, 100),
fontFace=r"C:\Windows\Fonts\ANTQUAB.TTF",
fontScale=56,
color=(255, 255, 0),
)
ia = put_ttf_font_at_exact_location_with_exact_size(
image=img,
text="Number 4",
coords=(59, 300),
color=(100, 0, 100),
font=r"C:\Windows\Fonts\ANTQUAB.TTF",
maxwidth=300,
maxheight=100,
fonttransparency=100,
)
ia1 = put_ttf_font_in_box_at_exact_location_with_exact_size(
image=img,
text="Number 5",
coords=(59, 300),
color=(100, 0, 100),
font=r"C:\Windows\Fonts\ANTQUAB.TTF",
maxwidth=300,
maxheight=100,
fonttransparency=0,
boxtransparency=0.7,
boxcolor=(255, 0, 0),
)
ia2 = put_ttf_font_in_circle_at_exact_location_with_exact_size(
image=img,
text="Number 6",
coords=(59, 300),
color=(100, 0, 100),
font=r"C:\Windows\Fonts\ANTQUAB.TTF",
maxwidth=300,
maxheight=100,
fonttransparency=50,
circletransparency=0.2,
circlecolor=(255, 0, 0),
)
ia3 = put_ttf_font_multiline_in_box_at_exact_location_with_exact_size(
image=img,
textwithnewline="Number 7\nNumber 7\nNumber 7",
coords=(59, 10),
color=(100, 0, 100),
font=r"C:\Windows\Fonts\ANTQUAB.TTF",
maxwidth=600,
maxheight=600,
fonttransparency=50,
boxtransparency=0.2,
boxcolor=(255, 0, 0),
boxborder=20,
)
ia4 = put_ttf_font_multiline_at_exact_location_with_exact_size(
image=img,
textwithnewline="Number 8\nNumber 8\nNumber 8",
coords=(59, 10),
color=(100, 0, 100),
font=r"C:\Windows\Fonts\ANTQUAB.TTF",
maxwidth=600,
maxheight=600,
fonttransparency=50,
)
ia5 = put_ttf_font_multiline_at_exact_center_location_with_exact_size(
image=img,
textwithnewline="Number 9\nNumber 9\nNumber 9",
coords=(300, 300),
color=(255, 255, 210),
font=r"C:\Windows\Fonts\ANTQUAB.TTF",
maxwidth=300,
maxheight=100,
fonttransparency=-1,
)
ia6 = put_ttf_font_multiline_in_box_at_exact_center_location_with_exact_size(
image=img,
textwithnewline="Number 10\nNumber 10\nNumber 10",
coords=(300, 300),
color=(255, 255, 210),
font=r"C:\Windows\Fonts\ANTQUAB.TTF",
maxwidth=300,
maxheight=100,
fonttransparency=50,
boxtransparency=0.2,
boxcolor=(255, 0, 0),
boxborder=20,
)
allimgs= [
imgresult1,
imgresult2,
imgresult3,
ia["result"],
ia1["result"],
ia2["result"],
ia3["result"],
ia4["result"],
ia5["result"],
ia6["result"],
]
for i,b in enumerate(allimgs):
save_cv_image(os.path.join('f:\\alltextimgs',str(i).zfill(6) + '.png'), b)
```
<img src="https://github.com/hansalemaos/screenshots/raw/main/texteffects/000000.png"/>
<img src="https://github.com/hansalemaos/screenshots/raw/main/texteffects/000000.png"/>
<img src="https://github.com/hansalemaos/screenshots/raw/main/texteffects/000001.png"/>
<img src="https://github.com/hansalemaos/screenshots/raw/main/texteffects/000002.png"/>
<img src="https://github.com/hansalemaos/screenshots/raw/main/texteffects/000003.png"/>
<img src="https://github.com/hansalemaos/screenshots/raw/main/texteffects/000004.png"/>
<img src="https://github.com/hansalemaos/screenshots/raw/main/texteffects/000005.png"/>
<img src="https://github.com/hansalemaos/screenshots/raw/main/texteffects/000006.png"/>
<img src="https://github.com/hansalemaos/screenshots/raw/main/texteffects/000007.png"/>
<img src="https://github.com/hansalemaos/screenshots/raw/main/texteffects/000008.png"/>
<img src="https://github.com/hansalemaos/screenshots/raw/main/texteffects/000009.png"/>
Raw data
{
"_id": null,
"home_page": "https://github.com/hansalemaos/a_cv2_text_effects",
"name": "a-cv2-text-effects",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "opencv,text",
"author": "Johannes Fischer",
"author_email": "<aulasparticularesdealemaosp@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/86/59/0bd89445ca6c1f133ea2e2c87503299c9ca552bd1ca712241e0782617b13/a_cv2_text_effects-0.10.tar.gz",
"platform": null,
"description": "\n# Text effects for OpenCV\n\n\n\n\n\n\n\n```python\n\n$pip install a-cv2-text-effects\n\n\n\nimport os\n\nfrom a_cv_imwrite_imread_plus import open_image_in_cv,save_cv_image\n\nfrom a_cv2_text_effects import (\n\n put_ttf_font_multiline_in_box_at_exact_center_location_with_exact_size,\n\n put_ttf_font_multiline_at_exact_center_location_with_exact_size,\n\n put_ttf_font_multiline_at_exact_location_with_exact_size,\n\n put_ttf_font_multiline_in_box_at_exact_location_with_exact_size,\n\n put_ttf_font_in_circle_at_exact_location_with_exact_size,\n\n put_ttf_font_in_box_at_exact_location_with_exact_size,\n\n put_ttf_font_at_exact_location_with_exact_size,\n\n putTrueTypeText,\n\n center_text_at_certain_size_at_a_specific_point,\n\n center_of_text_at_certain_size_at_a_specific_point_with_boxes,\n\n)\n\n\n\nimg = open_image_in_cv(\n\n \"https://raw.githubusercontent.com/hansalemaos/screenshots/main/merg6.png\"\n\n)\n\nmaxwidth = 150\n\nmaxheight = 150\n\n\n\n(\n\n imgresult1,\n\n ptLowerLeftTextOriginX2,\n\n ptLowerLeftTextOriginY2,\n\n intFontFace2,\n\n fltFontScale2,\n\n intFontThickness2,\n\n textSize2,\n\n) = center_of_text_at_certain_size_at_a_specific_point_with_boxes(\n\n img,\n\n \"Number 1\",\n\n maxwidth,\n\n maxheight,\n\n wheretoput=(200, 200),\n\n color=(255, 255, 0),\n\n add_thickness_each=10,\n\n rectangle_border_size=5,\n\n rectangle_border_colors=((244, 255, 0), (244, 0, 255)),\n\n)\n\n\n\n(\n\n imgresult2,\n\n ptLowerLeftTextOriginX,\n\n ptLowerLeftTextOriginY,\n\n intFontFace,\n\n fltFontScale,\n\n intFontThickness,\n\n textSize,\n\n) = center_text_at_certain_size_at_a_specific_point(\n\n img,\n\n \"Number 2\",\n\n maxwidth,\n\n maxheight,\n\n wheretoput=(100, 100),\n\n color=(255, 255, 0),\n\n add_thickness_each=10,\n\n)\n\n\n\nimgresult3 = putTrueTypeText(\n\n img=img,\n\n text=\"Number 3\",\n\n org=(100, 100),\n\n fontFace=r\"C:\\Windows\\Fonts\\ANTQUAB.TTF\",\n\n fontScale=56,\n\n color=(255, 255, 0),\n\n)\n\n\n\n\n\nia = put_ttf_font_at_exact_location_with_exact_size(\n\n image=img,\n\n text=\"Number 4\",\n\n coords=(59, 300),\n\n color=(100, 0, 100),\n\n font=r\"C:\\Windows\\Fonts\\ANTQUAB.TTF\",\n\n maxwidth=300,\n\n maxheight=100,\n\n fonttransparency=100,\n\n)\n\n\n\nia1 = put_ttf_font_in_box_at_exact_location_with_exact_size(\n\n image=img,\n\n text=\"Number 5\",\n\n coords=(59, 300),\n\n color=(100, 0, 100),\n\n font=r\"C:\\Windows\\Fonts\\ANTQUAB.TTF\",\n\n maxwidth=300,\n\n maxheight=100,\n\n fonttransparency=0,\n\n boxtransparency=0.7,\n\n boxcolor=(255, 0, 0),\n\n)\n\n\n\nia2 = put_ttf_font_in_circle_at_exact_location_with_exact_size(\n\n image=img,\n\n text=\"Number 6\",\n\n coords=(59, 300),\n\n color=(100, 0, 100),\n\n font=r\"C:\\Windows\\Fonts\\ANTQUAB.TTF\",\n\n maxwidth=300,\n\n maxheight=100,\n\n fonttransparency=50,\n\n circletransparency=0.2,\n\n circlecolor=(255, 0, 0),\n\n)\n\n\n\n\n\nia3 = put_ttf_font_multiline_in_box_at_exact_location_with_exact_size(\n\n image=img,\n\n textwithnewline=\"Number 7\\nNumber 7\\nNumber 7\",\n\n coords=(59, 10),\n\n color=(100, 0, 100),\n\n font=r\"C:\\Windows\\Fonts\\ANTQUAB.TTF\",\n\n maxwidth=600,\n\n maxheight=600,\n\n fonttransparency=50,\n\n boxtransparency=0.2,\n\n boxcolor=(255, 0, 0),\n\n boxborder=20,\n\n)\n\n\n\n\n\nia4 = put_ttf_font_multiline_at_exact_location_with_exact_size(\n\n image=img,\n\n textwithnewline=\"Number 8\\nNumber 8\\nNumber 8\",\n\n coords=(59, 10),\n\n color=(100, 0, 100),\n\n font=r\"C:\\Windows\\Fonts\\ANTQUAB.TTF\",\n\n maxwidth=600,\n\n maxheight=600,\n\n fonttransparency=50,\n\n)\n\n\n\n\n\nia5 = put_ttf_font_multiline_at_exact_center_location_with_exact_size(\n\n image=img,\n\n textwithnewline=\"Number 9\\nNumber 9\\nNumber 9\",\n\n coords=(300, 300),\n\n color=(255, 255, 210),\n\n font=r\"C:\\Windows\\Fonts\\ANTQUAB.TTF\",\n\n maxwidth=300,\n\n maxheight=100,\n\n fonttransparency=-1,\n\n)\n\n\n\n\n\nia6 = put_ttf_font_multiline_in_box_at_exact_center_location_with_exact_size(\n\n image=img,\n\n textwithnewline=\"Number 10\\nNumber 10\\nNumber 10\",\n\n coords=(300, 300),\n\n color=(255, 255, 210),\n\n font=r\"C:\\Windows\\Fonts\\ANTQUAB.TTF\",\n\n maxwidth=300,\n\n maxheight=100,\n\n fonttransparency=50,\n\n boxtransparency=0.2,\n\n boxcolor=(255, 0, 0),\n\n boxborder=20,\n\n)\n\n\n\n\n\nallimgs= [\n\n imgresult1,\n\n imgresult2,\n\n imgresult3,\n\n ia[\"result\"],\n\n ia1[\"result\"],\n\n ia2[\"result\"],\n\n ia3[\"result\"],\n\n ia4[\"result\"],\n\n ia5[\"result\"],\n\n ia6[\"result\"],\n\n\n\n ]\n\nfor i,b in enumerate(allimgs):\n\n save_cv_image(os.path.join('f:\\\\alltextimgs',str(i).zfill(6) + '.png'), b)\n\n\n\n```\n\n\n\n\n\n<img src=\"https://github.com/hansalemaos/screenshots/raw/main/texteffects/000000.png\"/>\n\n\n\n\n\n<img src=\"https://github.com/hansalemaos/screenshots/raw/main/texteffects/000000.png\"/>\n\n\n\n\n\n\n\n<img src=\"https://github.com/hansalemaos/screenshots/raw/main/texteffects/000001.png\"/>\n\n\n\n\n\n\n\n<img src=\"https://github.com/hansalemaos/screenshots/raw/main/texteffects/000002.png\"/>\n\n\n\n\n\n\n\n<img src=\"https://github.com/hansalemaos/screenshots/raw/main/texteffects/000003.png\"/>\n\n\n\n\n\n\n\n<img src=\"https://github.com/hansalemaos/screenshots/raw/main/texteffects/000004.png\"/>\n\n\n\n\n\n\n\n<img src=\"https://github.com/hansalemaos/screenshots/raw/main/texteffects/000005.png\"/>\n\n\n\n\n\n\n\n<img src=\"https://github.com/hansalemaos/screenshots/raw/main/texteffects/000006.png\"/>\n\n\n\n\n\n\n\n<img src=\"https://github.com/hansalemaos/screenshots/raw/main/texteffects/000007.png\"/>\n\n\n\n\n\n\n\n<img src=\"https://github.com/hansalemaos/screenshots/raw/main/texteffects/000008.png\"/>\n\n\n\n\n\n\n\n<img src=\"https://github.com/hansalemaos/screenshots/raw/main/texteffects/000009.png\"/>\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Text effects for OpenCV",
"version": "0.10",
"split_keywords": [
"opencv",
"text"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "7ae164ae7135e12aa7c5d59e5d610880becbf22a857c8f68206ff972b5193916",
"md5": "8a94bbb288d3f1c07900b80f06e181d6",
"sha256": "8fbcff78343f6d11b02d5a38a196fe357a4760e21d9ee9d43c08452d1551f712"
},
"downloads": -1,
"filename": "a_cv2_text_effects-0.10-py3-none-any.whl",
"has_sig": false,
"md5_digest": "8a94bbb288d3f1c07900b80f06e181d6",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 11318,
"upload_time": "2023-01-14T09:32:58",
"upload_time_iso_8601": "2023-01-14T09:32:58.024099Z",
"url": "https://files.pythonhosted.org/packages/7a/e1/64ae7135e12aa7c5d59e5d610880becbf22a857c8f68206ff972b5193916/a_cv2_text_effects-0.10-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "86590bd89445ca6c1f133ea2e2c87503299c9ca552bd1ca712241e0782617b13",
"md5": "949c0c39ea36c39dfff4e0ab7cfdf70e",
"sha256": "a2e8676b201b4e3863b70d8862135cc851bca7f7a555c611fbeb63b56c4e0c15"
},
"downloads": -1,
"filename": "a_cv2_text_effects-0.10.tar.gz",
"has_sig": false,
"md5_digest": "949c0c39ea36c39dfff4e0ab7cfdf70e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 10700,
"upload_time": "2023-01-14T09:32:59",
"upload_time_iso_8601": "2023-01-14T09:32:59.541772Z",
"url": "https://files.pythonhosted.org/packages/86/59/0bd89445ca6c1f133ea2e2c87503299c9ca552bd1ca712241e0782617b13/a_cv2_text_effects-0.10.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-01-14 09:32:59",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "hansalemaos",
"github_project": "a_cv2_text_effects",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "a-cv2-text-effects"
}