Skip to main content

Image Captioner

PyPI - Implementation

Command line python script for adding captions to the images based on the metadata, filename or user input.

Example

Source Image:

imagecaptioner kitten.jpg --align=tr

result:

imagecaptioner kitten.jpg -c "LOVELY KITTEN, ##Software                      ##DateTime" --color=#e4eeed --size=30 --bold=2 -o "captioned2_kitten.jpg"

result:

Installation

It is required to install imagecaptioner dependency from pypi repository.

pip install imagecaptioner

Usage

CLI

➜  ~/pictures imagecaptioner --help      
usage: imagecaptioner path caption_expression [options]

positional arguments:
  path                  File or directory location

optional arguments:
  -h, --help            show this help message and exit
  -c CAPTION, --caption CAPTION
                        Caption with variables support taken from metatags. To access variable in caption use e.g. ##DateTime
  -m, --metatags        Show file metatags
  -df DATEFORMAT, --dateformat DATEFORMAT
                        Date time format
  -o OUTPUT, --output OUTPUT
                        Output file or directory, by default adds 'captioned_' prefix
  -r, --overwrite       Overwrite already captioned photo with new one
  -p, --preview         Preview mode. Show only mode instead of save. Useful for testing. Only for specific file.
  --font FONT           Font type
  --size SIZE           Font size, by default automatically chosen.
  --color COLOR         Font color
  --bold BOLD           Font bold
  --align ALIGN         Text alignment. Possible values: BOTTOM_LEFT, BOTTOM_RIGHT, TOP_LEFT, TOP_RIGHT, CENTER. 
  It can be used also with shorter versions like: bl, br, tl, tr, c
  --singlethread        Use single thread (only works for directory)
  -v, --verbose         Increase logging severity

Examples:
    > imagecaptioner 20190116_111115.jpg -c "Party, ##DateTime - Captured with phone ##Make ##Model"
    > imagecaptioner images/ --output=captioned_images
    > imagecaptioner 20190116_111115.jpg -p --font=fonts/Lato-Regular.ttf --size=120 --color=#030360 --bold=3
    > imagecaptioner 20190116_111115.jpg -r -dateformat "%H:%M" --output=captioned.jpg

    Show metatags:
    > imagecaptioner 20190116_111115.jpg -m
    > imagecaptioner images/ -m
    

Python library

It is possible to import imagecaptioner lib to your python project

Import library:

from imagecaptioner.captioner import ImageCaptioner

It could be simply used:

ImageCaptioner.add_captions(path="images/", output="captined_images", overwrite=1)

Overwrite image with caption:

ImageCaptioner.add_captions(
    path="20190116_111115.jpg",
    caption="SUPER PARTY, ##DateTime captured with ##Made",
    dateformat="%H:%M",
    output="20190116_111115.jpg",
    overwrite=1,
    preview=None,
    font=None,
    size=86,
    color="#F5992A",
    bold=2,
)

Licence

MIT

Metadata

Release files for imagecaptioner 0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for imagecaptioner 0.4
File Size Uploaded
imagecaptioner-0.4.tar.gz 346.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for imagecaptioner 0.4
File Interpreter ABI Platform
imagecaptioner-0.4-py3-none-any.whl Python 3 none any Details

Total release size: 692.0 kB

Release files / imagecaptioner-0.4.tar.gz

Download URL imagecaptioner-0.4.tar.gz
Size 346.4 kB
Tags Source
SHA-256 checksum
How to use checksums
7ef23fd6e80e926ae6d874f008a9285ef03c6870d3d99da8a7dc6f3f8937c379
BLAKE2b-256 checksum
How to use checksums
c38c8a978c82607b16de98ceeb20eec5ee7ad0167a0d1e61e18fb7eb87dc75bb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Release files / imagecaptioner-0.4-py3-none-any.whl

Download URL imagecaptioner-0.4-py3-none-any.whl
Size 345.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4cfe54141b867e5160415c18e8e7ee94dcd9e778aa3cb8bd7d7d0dc9f090b2f6
BLAKE2b-256 checksum
How to use checksums
9f98c7e3fc3bf8040233f455e6268a41a815a6e6536e57b6e6b850ae4a6a3d70
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Release history Release notifications | RSS feed

This release

0.4 This release

2 release files

0.3

2 release files

0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page