Skip to main content

方便地制作字符画与字符视频 ~

Project description

char_art

方便地制作字符画与字符视频 ~


0. 引言

制作字符画和字符视频的脚本很多人都写过, 而我写该库的目的主要是为了:

  1. 让制作字符画与字符视频更方便, 只需一行命令即可完成从生成到保存的全部过程
  2. 做了许多优化, 让生成字符画和字符视频更加高效

1. 安装

使用以下命令安装该库, 使用该库的基本功能:

pip install char_art

若需要保存生成的字符画和字符视频, 则需要额外安装 pygame 库, 或者可以直接用以下命令进行安装

pip install char_art[save]

2. 快速开始

  • 生成一张图片的字符画

    python -m char_art display 'my_image.jpg' -s 120 37
    
  • 生成一段视频的字符视频

    python -m char_art display 'my_video.mp4' -v -s 80 30
    
  • 保存生成的字符画 (需要 pygame 库)

    python -m char_art save 'my_image.jpg' 'save_file.jpg' -s 120 37
    
  • 保存生成的字符视频 (需要 pygame 库)

    python -m char_art save 'my_video.mp4' 'save_file.mp4' -v -s 80 30
    

3. 使用帮助

usage: python -m char_art [-h] [-v] {display,save} ...

positional arguments:
  {display,save}
    display       展示字符画或字符视频
    save          保存字符画为图像文件 / 字符视频为视频文件

options:
  -h, --help      show this help message and exit
  -v, --version   show program's version number and exit
usage: python -m char_art display [-h] [-v] -s WIDTH HEIGHT [-c CHARS] [-l] file

positional arguments:
  file                  图像或视频的文件路径

options:
  -h, --help            show this help message and exit
  -v, --video           展示字符视频, 若不设置则为字符画
  -s, --size WIDTH HEIGHT
                        字符画或字符视频的尺寸, 按字符数量计
  -c, --chars CHARS     使用的字符序列 (默认为 ' .-+{#')
  -l, --load            在展示字符视频前加载并缓存所有字符帧, 使得播放时更流畅
usage: python -m char_art save [-h] [-v] -s WIDTH HEIGHT [-c CHARS] [--font FONT] [--font-size FONT_SIZE] [--spacing SPACING] [--fill FILL] [--bg BG] [--scale SCALE] [--fourcc FOURCC]
                               file save_file

positional arguments:
  file                  图像或视频的文件路径
  save_file             生成的图像或视频的保存路径

options:
  -h, --help            show this help message and exit
  -v, --video           保存字符视频, 若不设置则为字符画
  -s, --size WIDTH HEIGHT
                        字符画或字符视频的尺寸, 按字符数量计
  -c, --chars CHARS     使用的字符序列 (默认为 ' .-+{#')
  --font FONT           字体文件路径, **需要等宽字体** (默认为系统字体 Courier New)
  --font-size FONT_SIZE
                        字体大小 (默认为 15)
  --spacing SPACING     行间距 (默认为 0)
  --fill FILL           字符前景色 (默认为白色 '#FFFFFF')
  --bg BG               背景色 (默认为黑色 '#000000')
  --scale SCALE         按比例缩放生成的图像或视频尺寸 (默认不缩放)
  --fourcc FOURCC       视频编码器 (默认为 'mp4v')

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

char_art-0.1.1.tar.gz (11.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

char_art-0.1.1-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file char_art-0.1.1.tar.gz.

File metadata

  • Download URL: char_art-0.1.1.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.0

File hashes

Hashes for char_art-0.1.1.tar.gz
Algorithm Hash digest
SHA256 45eb0ed77a2a05df1982a1a87eba367f998fc52774f7e1e67fcf5c92d98df9e0
MD5 2f2758edf077e9e76543af2e5296b8a8
BLAKE2b-256 ac72fdd05b6cea6101cd040b1e9ed2bbc3ab49d3de607ae8600de5f3a2b40789

See more details on using hashes here.

File details

Details for the file char_art-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: char_art-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 11.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.0

File hashes

Hashes for char_art-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 43ebf972b401126cc59ab43cbb57981f2893a5ea17800edad90215af0e921799
MD5 b18281352cb4eb27b6549ed29aa0c7e9
BLAKE2b-256 8a47ebfb5cf8c6b5f72a82ce666f830f017781cf5596af21e00292d2c92176fb

See more details on using hashes here.

Supported by

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