char-art


Namechar-art JSON
Version 0.1.1 PyPI version JSON
download
home_pageNone
Summary方便地制作字符画与字符视频 ~
upload_time2025-03-14 16:09:55
maintainerNone
docs_urlNone
authorNone
requires_python>=3.7.0
licenseMIT License Copyright (c) [2025] [Liu Wei] Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords char_art character image character video
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # char_art

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

---

## 0. 引言

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

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

---

## 1. 安装

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

  ```commandline
  pip install char_art
  ```

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

  ```commandline
  pip install char_art[save]
  ```

---

## 2. 快速开始

- 生成一张图片的字符画
  ```commandline
  python -m char_art display 'my_image.jpg' -s 120 37
  ```

- 生成一段视频的字符视频
  ```commandline
  python -m char_art display 'my_video.mp4' -v -s 80 30
  ```

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

- 保存生成的字符视频 (需要 pygame 库)
  ```commandline
  python -m char_art save 'my_video.mp4' 'save_file.mp4' -v -s 80 30
  ```

---

## 3. 使用帮助

```commandline
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
```

```commandline
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            在展示字符视频前加载并缓存所有字符帧, 使得播放时更流畅
```

```commandline
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')
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "char-art",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7.0",
    "maintainer_email": "Liu Wei <23S112099@stu.hit.edu.cn>",
    "keywords": "char_art, character image, character video",
    "author": null,
    "author_email": "Liu Wei <23S112099@stu.hit.edu.cn>",
    "download_url": "https://files.pythonhosted.org/packages/ac/72/fdd05b6cea6101cd040b1e9ed2bbc3ab49d3de607ae8600de5f3a2b40789/char_art-0.1.1.tar.gz",
    "platform": null,
    "description": "# char_art\r\n\r\n\u65b9\u4fbf\u5730\u5236\u4f5c\u5b57\u7b26\u753b\u4e0e\u5b57\u7b26\u89c6\u9891 ~\r\n\r\n---\r\n\r\n## 0. \u5f15\u8a00\r\n\r\n\u5236\u4f5c\u5b57\u7b26\u753b\u548c\u5b57\u7b26\u89c6\u9891\u7684\u811a\u672c\u5f88\u591a\u4eba\u90fd\u5199\u8fc7, \u800c\u6211\u5199\u8be5\u5e93\u7684\u76ee\u7684\u4e3b\u8981\u662f\u4e3a\u4e86:\r\n\r\n1. \u8ba9\u5236\u4f5c\u5b57\u7b26\u753b\u4e0e\u5b57\u7b26\u89c6\u9891\u66f4\u65b9\u4fbf, \u53ea\u9700\u4e00\u884c\u547d\u4ee4\u5373\u53ef\u5b8c\u6210\u4ece\u751f\u6210\u5230\u4fdd\u5b58\u7684\u5168\u90e8\u8fc7\u7a0b\r\n2. \u505a\u4e86\u8bb8\u591a\u4f18\u5316, \u8ba9\u751f\u6210\u5b57\u7b26\u753b\u548c\u5b57\u7b26\u89c6\u9891\u66f4\u52a0\u9ad8\u6548\r\n\r\n---\r\n\r\n## 1. \u5b89\u88c5\r\n\r\n\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5\u8be5\u5e93, \u4f7f\u7528\u8be5\u5e93\u7684\u57fa\u672c\u529f\u80fd:\r\n\r\n  ```commandline\r\n  pip install char_art\r\n  ```\r\n\r\n\u82e5\u9700\u8981\u4fdd\u5b58\u751f\u6210\u7684\u5b57\u7b26\u753b\u548c\u5b57\u7b26\u89c6\u9891, \u5219\u9700\u8981\u989d\u5916\u5b89\u88c5 **pygame** \u5e93, \u6216\u8005\u53ef\u4ee5\u76f4\u63a5\u7528\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u884c\u5b89\u88c5\r\n\r\n  ```commandline\r\n  pip install char_art[save]\r\n  ```\r\n\r\n---\r\n\r\n## 2. \u5feb\u901f\u5f00\u59cb\r\n\r\n- \u751f\u6210\u4e00\u5f20\u56fe\u7247\u7684\u5b57\u7b26\u753b\r\n  ```commandline\r\n  python -m char_art display 'my_image.jpg' -s 120 37\r\n  ```\r\n\r\n- \u751f\u6210\u4e00\u6bb5\u89c6\u9891\u7684\u5b57\u7b26\u89c6\u9891\r\n  ```commandline\r\n  python -m char_art display 'my_video.mp4' -v -s 80 30\r\n  ```\r\n\r\n- \u4fdd\u5b58\u751f\u6210\u7684\u5b57\u7b26\u753b (\u9700\u8981 pygame \u5e93)\r\n  ```commandline\r\n  python -m char_art save 'my_image.jpg' 'save_file.jpg' -s 120 37\r\n  ```\r\n\r\n- \u4fdd\u5b58\u751f\u6210\u7684\u5b57\u7b26\u89c6\u9891 (\u9700\u8981 pygame \u5e93)\r\n  ```commandline\r\n  python -m char_art save 'my_video.mp4' 'save_file.mp4' -v -s 80 30\r\n  ```\r\n\r\n---\r\n\r\n## 3. \u4f7f\u7528\u5e2e\u52a9\r\n\r\n```commandline\r\nusage: python -m char_art [-h] [-v] {display,save} ...\r\n\r\npositional arguments:\r\n  {display,save}\r\n    display       \u5c55\u793a\u5b57\u7b26\u753b\u6216\u5b57\u7b26\u89c6\u9891\r\n    save          \u4fdd\u5b58\u5b57\u7b26\u753b\u4e3a\u56fe\u50cf\u6587\u4ef6 / \u5b57\u7b26\u89c6\u9891\u4e3a\u89c6\u9891\u6587\u4ef6\r\n\r\noptions:\r\n  -h, --help      show this help message and exit\r\n  -v, --version   show program's version number and exit\r\n```\r\n\r\n```commandline\r\nusage: python -m char_art display [-h] [-v] -s WIDTH HEIGHT [-c CHARS] [-l] file\r\n\r\npositional arguments:\r\n  file                  \u56fe\u50cf\u6216\u89c6\u9891\u7684\u6587\u4ef6\u8def\u5f84\r\n\r\noptions:\r\n  -h, --help            show this help message and exit\r\n  -v, --video           \u5c55\u793a\u5b57\u7b26\u89c6\u9891, \u82e5\u4e0d\u8bbe\u7f6e\u5219\u4e3a\u5b57\u7b26\u753b\r\n  -s, --size WIDTH HEIGHT\r\n                        \u5b57\u7b26\u753b\u6216\u5b57\u7b26\u89c6\u9891\u7684\u5c3a\u5bf8, \u6309\u5b57\u7b26\u6570\u91cf\u8ba1\r\n  -c, --chars CHARS     \u4f7f\u7528\u7684\u5b57\u7b26\u5e8f\u5217 (\u9ed8\u8ba4\u4e3a ' .-+{#')\r\n  -l, --load            \u5728\u5c55\u793a\u5b57\u7b26\u89c6\u9891\u524d\u52a0\u8f7d\u5e76\u7f13\u5b58\u6240\u6709\u5b57\u7b26\u5e27, \u4f7f\u5f97\u64ad\u653e\u65f6\u66f4\u6d41\u7545\r\n```\r\n\r\n```commandline\r\nusage: 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]\r\n                               file save_file\r\n\r\npositional arguments:\r\n  file                  \u56fe\u50cf\u6216\u89c6\u9891\u7684\u6587\u4ef6\u8def\u5f84\r\n  save_file             \u751f\u6210\u7684\u56fe\u50cf\u6216\u89c6\u9891\u7684\u4fdd\u5b58\u8def\u5f84\r\n\r\noptions:\r\n  -h, --help            show this help message and exit\r\n  -v, --video           \u4fdd\u5b58\u5b57\u7b26\u89c6\u9891, \u82e5\u4e0d\u8bbe\u7f6e\u5219\u4e3a\u5b57\u7b26\u753b\r\n  -s, --size WIDTH HEIGHT\r\n                        \u5b57\u7b26\u753b\u6216\u5b57\u7b26\u89c6\u9891\u7684\u5c3a\u5bf8, \u6309\u5b57\u7b26\u6570\u91cf\u8ba1\r\n  -c, --chars CHARS     \u4f7f\u7528\u7684\u5b57\u7b26\u5e8f\u5217 (\u9ed8\u8ba4\u4e3a ' .-+{#')\r\n  --font FONT           \u5b57\u4f53\u6587\u4ef6\u8def\u5f84, **\u9700\u8981\u7b49\u5bbd\u5b57\u4f53** (\u9ed8\u8ba4\u4e3a\u7cfb\u7edf\u5b57\u4f53 Courier New)\r\n  --font-size FONT_SIZE\r\n                        \u5b57\u4f53\u5927\u5c0f (\u9ed8\u8ba4\u4e3a 15)\r\n  --spacing SPACING     \u884c\u95f4\u8ddd (\u9ed8\u8ba4\u4e3a 0)\r\n  --fill FILL           \u5b57\u7b26\u524d\u666f\u8272 (\u9ed8\u8ba4\u4e3a\u767d\u8272 '#FFFFFF')\r\n  --bg BG               \u80cc\u666f\u8272 (\u9ed8\u8ba4\u4e3a\u9ed1\u8272 '#000000')\r\n  --scale SCALE         \u6309\u6bd4\u4f8b\u7f29\u653e\u751f\u6210\u7684\u56fe\u50cf\u6216\u89c6\u9891\u5c3a\u5bf8 (\u9ed8\u8ba4\u4e0d\u7f29\u653e)\r\n  --fourcc FOURCC       \u89c6\u9891\u7f16\u7801\u5668 (\u9ed8\u8ba4\u4e3a 'mp4v')\r\n```\r\n",
    "bugtrack_url": null,
    "license": "MIT License\r\n        \r\n        Copyright (c) [2025] [Liu Wei]\r\n        \r\n        Permission is hereby granted, free of charge, to any person obtaining a copy\r\n        of this software and associated documentation files (the \"Software\"), to deal\r\n        in the Software without restriction, including without limitation the rights\r\n        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n        copies of the Software, and to permit persons to whom the Software is\r\n        furnished to do so, subject to the following conditions:\r\n        \r\n        The above copyright notice and this permission notice shall be included in all\r\n        copies or substantial portions of the Software.\r\n        \r\n        THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\n        SOFTWARE.\r\n        ",
    "summary": "\u65b9\u4fbf\u5730\u5236\u4f5c\u5b57\u7b26\u753b\u4e0e\u5b57\u7b26\u89c6\u9891 ~",
    "version": "0.1.1",
    "project_urls": {
        "Homepage": "https://github.com/AomandeNiuma/char_art"
    },
    "split_keywords": [
        "char_art",
        " character image",
        " character video"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "8a47ebfb5cf8c6b5f72a82ce666f830f017781cf5596af21e00292d2c92176fb",
                "md5": "b18281352cb4eb27b6549ed29aa0c7e9",
                "sha256": "43ebf972b401126cc59ab43cbb57981f2893a5ea17800edad90215af0e921799"
            },
            "downloads": -1,
            "filename": "char_art-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b18281352cb4eb27b6549ed29aa0c7e9",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7.0",
            "size": 11357,
            "upload_time": "2025-03-14T16:09:54",
            "upload_time_iso_8601": "2025-03-14T16:09:54.116558Z",
            "url": "https://files.pythonhosted.org/packages/8a/47/ebfb5cf8c6b5f72a82ce666f830f017781cf5596af21e00292d2c92176fb/char_art-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "ac72fdd05b6cea6101cd040b1e9ed2bbc3ab49d3de607ae8600de5f3a2b40789",
                "md5": "2f2758edf077e9e76543af2e5296b8a8",
                "sha256": "45eb0ed77a2a05df1982a1a87eba367f998fc52774f7e1e67fcf5c92d98df9e0"
            },
            "downloads": -1,
            "filename": "char_art-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "2f2758edf077e9e76543af2e5296b8a8",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7.0",
            "size": 11110,
            "upload_time": "2025-03-14T16:09:55",
            "upload_time_iso_8601": "2025-03-14T16:09:55.541877Z",
            "url": "https://files.pythonhosted.org/packages/ac/72/fdd05b6cea6101cd040b1e9ed2bbc3ab49d3de607ae8600de5f3a2b40789/char_art-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-03-14 16:09:55",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "AomandeNiuma",
    "github_project": "char_art",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "char-art"
}
        
Elapsed time: 1.00865s