Skip to main content

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

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

imagecaptioner-0.4.tar.gz (346.4 kB view details)

Uploaded Source

Built Distribution

imagecaptioner-0.4-py3-none-any.whl (345.6 kB view details)

Uploaded Python 3

File details

Details for the file imagecaptioner-0.4.tar.gz.

File metadata

  • Download URL: imagecaptioner-0.4.tar.gz
  • Upload date:
  • Size: 346.4 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for imagecaptioner-0.4.tar.gz
Algorithm Hash digest
SHA256 7ef23fd6e80e926ae6d874f008a9285ef03c6870d3d99da8a7dc6f3f8937c379
MD5 8d2f75e5b1cea109a306e5079fb7d372
BLAKE2b-256 c38c8a978c82607b16de98ceeb20eec5ee7ad0167a0d1e61e18fb7eb87dc75bb

See more details on using hashes here.

File details

Details for the file imagecaptioner-0.4-py3-none-any.whl.

File metadata

  • Download URL: imagecaptioner-0.4-py3-none-any.whl
  • Upload date:
  • Size: 345.6 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for imagecaptioner-0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 4cfe54141b867e5160415c18e8e7ee94dcd9e778aa3cb8bd7d7d0dc9f090b2f6
MD5 76f85e89588faf8b1f800d9af20fc564
BLAKE2b-256 9f98c7e3fc3bf8040233f455e6268a41a815a6e6536e57b6e6b850ae4a6a3d70

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page