Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gabrielepicco/pynter
Minimal Python utility for writing textual caption on images
https://github.com/gabrielepicco/pynter
image-captioning write-on-image
Last synced: 1 day ago
JSON representation
Minimal Python utility for writing textual caption on images
- Host: GitHub
- URL: https://github.com/gabrielepicco/pynter
- Owner: GabrielePicco
- License: mit
- Created: 2021-05-16T09:04:19.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-10-31T13:47:23.000Z (almost 3 years ago)
- Last Synced: 2024-03-15T12:26:46.063Z (7 months ago)
- Topics: image-captioning, write-on-image
- Language: Python
- Homepage:
- Size: 42 KB
- Stars: 12
- Watchers: 3
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
Pynter
======.. image:: https://img.shields.io/pypi/v/pynter.svg
:target: https://pypi.python.org/pypi/pynter
:alt: Latest PyPI versionMinimal utility for generating images with textual caption
Usage
-----1. Download an image
curl https://i.imgur.com/XQCKcC9.jpg -o ./image.jpg
2. Download a font
curl https://fonts.google.com/download?family=Roboto -o ./roboto.zip ; unzip ./roboto.zip -d ./Roboto
3. Provide a caption and Generate the image::
from pynter.pynter import generate_captioned
font_path = './Roboto/Roboto-Regular.ttf'
image_path = './image.jpg'
im = generate_captioned('China lands rover on Mars'.upper(), image_path=image_path, size=(1080, 1350),
font_path=font_path, filter_color=(0, 0, 0, 40))
im.show()
im.convert('RGB').save('drawn_image.jpg')Results will look like:
.. image:: https://i.imgur.com/fS6vPNm.jpg
Image Generation
----------------generate_captioned( text: str,
image_path,
size: Optional[Tuple[int, int]] = None,
font_path: str = None,
text_align: TextAlign = TextAlign.LEFT,
bottom_margin: Optional[float] = 0.07,
top_margin: Optional[float] = None,
left_margin: float = 0.2,
right_margin: float = 0.2,
character_ratio: float = 0.07,
filter_color: Tuple[int, int, int, int] = (0, 0, 0, 0),
text_background_color: Tuple[int, int, int, int] = (0, 0, 0, 180),
text_background_padding: float = 0.2,
text_background_mode: TextBackgroundMode = TextBackgroundMode.STRIPE,
filters: [BuiltinFilter] = [],
color: Tuple[int, int, int, int] = (255, 255, 255, 255)) -> Image:Installation
------------pip install pynter