# comicpy
Tool to create CBR or CBZ files.
Extracts images from PDF, ZIP, CBR files, generating comic files respecting their original order.
> [!Important]
>> The original files are not altered.
>
## Features
* Convert `PDF` file to `CBR` or `CBZ` files (by default).
* Convert `RAR` files to `CBR` files.
* Convert `ZIP` files to `CBZ` files.
* Scan in given directory and filter `PDF`, `ZIP`, `RAR` files depending on the given extension, convert them into `CBR` or `CBZ` files, generating individual files or consolidated into one.
* Scan in the given directory and filter `CBR`, `CBZ` files allowing to merge them all into one.
* Extract `CBR` or `CBZ` files from `RAR` or `ZIP` archives.
* Support for password protected `RAR` or `ZIP` archives.
* Convert image directories (*jpeg*, *png*, *jpg*) to `CBR` or `CBZ` files.
> [!Important]
>> 1. For full operation of `comicpy` when using RAR files, you must have available the `rar` command, download and install it from the official site, [**rarlab - rar/unrar command**](https://www.rarlab.com/download.htm).
>
>> 2. Some PDF files *contain multiple images on the same page*, which may be *repeated* within the *same file*; converting the PDF file <u>will remove all duplicate images</u>. <u>This is due to the original construction and layout of the source PDF file</u>. Therefore, as a result, there may be fewer or more pages compared to the original PDF file, this does *not necessarily indicate that the work of this tool (**comicpy**) is flawed or faulty*.
>
>> Any problem, suggestion, doubt, leave it in [*Issues*](https://github.com/kurotom/comicpy/issues) of the repository.
>
# Installation
```bash
pip install comicpy
```
# Usage
## CLI - usage
Command help.
```bash
$ comicpy -h
```
### File usage
| Command | Description |
|-|-|
| --type f | File. |
| -p PATH, --path PATH | Path of file. |
| --motorPDF {pypdf} | PDF library to use. |
| -c {rar,zip}, --compressor {rar,zip} | Type of compressor to use. |
| --check | Check the CBR or CBZ files created. |
| -u {b,kb,mb,gb}, --unit {b,kb,mb,gb} | Unit of measure of data size. Default is "mb". |
| --password PASSWORD | Password of file protected. |
| --resize {preserve,small,medium,large} | Resize images. |
| --progress | Shows file in progress. |
```bash
$ comicpy --type f -p file.PDF --check -u kb
$
$ comicpy --type f -p file.rar --check
$
$ comicpy --type f -p file.zip --check --password PASS
$
$ comicpy --type f -p file.rar --check --resize small
```
### Directory usage
| Command | Description |
|-|-|
| --type d | Directory. |
| -p PATH, --path PATH | Path of directory. |
| --filter {pdf,rar,zip,cbr,cbz,images} | Filter files on directory. Default is "zip". |
| --motorPDF {pypdf} | PDF library to use. |
| -c {rar,zip}, --compressor {rar,zip} | Type of compressor to use. Default is "zip".|
| --check | Check the CBR or CBZ files created. |
| --join | Join or does not files thath are in the directory. Default is "False". |
| -u {b,kb,mb,gb}, --unit {b,kb,mb,gb} | Unit of measure of data size. Default is "mb". |
| --password PASSWORD | Password of file protected. |
| --resize {preserve,small,medium,large} | Resize images. |
| --progress | Shows file in progress. |
```bash
$ comicpy --type d -p rars_dir --filter rar -c rar --check --join -o prefix_final_ --password PASS
$ for i in $(ls -d Zip_Dir_*/); do
> comicpy --type d -p "$i" --filter zip -c zip --check -o ${i: 0:-1} --join
> done
$ comicpy --type d -p rars_dir --filter rar -c rar --check --join -o prefix_final_ --password PASS --resize preserve
$ comicpy --type d -p Comic_vol1/ --compress zip --filter images --check --progress --join
```
## Development - usage
> `path='.'` parameter indicates that files will be written by default to the current directory. It can be changed.
## Single PDF, RAR, ZIP file -> CBZ or CBR
```python
>>> from comicpy import ComicPy
>>>
>>> file = "fileComic.pdf"
>>>
>>> comic = ComicPy(unit='mb')
>>>
>>> metadata = comic.process_pdf(
... filename=file,
... compressor='zip'
... )
>>>
>>> print(metadata)
[{'name': './Converted_comicpy/fileComic/fileComic.cbz', 'size': '193.24 MB'}]
>>>
>>> comic.check_integrity(filename=metadata[0]['name'])
File "fileComic.cbz" is valid?: "True"
True
>>>
```
## Directory with PDFs, RARs, ZIPs files -> CBZ or CBR
> The `join` parameter indicates whether all found files are merged or treated as individual files.
* Example, directory with RAR files - `join=False`
```python
>>> from comicpy import ComicPy
>>>
>>> dir = 'ComicVol1'
>>>
>>> comic = ComicPy(unit='GB')
>>>
>>> metadata = comic.process_dir(
... directory_path=dir,
... extension_filter='rar',
... compressor='rar',
... password=None,
... join=False
... )
>>> print(metadata)
[{'name': './Converted_comicpy/ComicVol1/chapter_1.cbr', 'size': '0.03 GB'}, {'name': './Converted_comicpy/ComicVol1/chapter_2.cbr', 'size': '0.02 GB'}]
>>>
>>>
>>> for item in metadata:
... comic.check_integrity(
... filename=item['name'],
... show=True
... )
...
File "chapter_1.cbr" is valid?: "True"
True
File "chapter_2.cbr" is valid?: "True"
True
>>>
```
* Example, directory with RAR files - `join=True`
```python
>>> from comicpy import ComicPy
>>>
>>> dir = 'ComicVol1'
>>>
>>> comic = ComicPy(unit='GB')
>>>
>>> metadata = comic.process_dir(
... directory_path=dir,
... extension_filter='rar',
... compressor='rar',
... password=None,
... join=True
... )
>>>
>>> print(metadata)
[{'name': './Converted_comicpy/ComicVol1/chapter_1.cbr', 'size': '0.09 GB'}]
>>>
>>> for item in metadata:
... comic.check_integrity(
... filename=item['name'],
... show=True
... )
...
File "chapter_1.cbr" is valid?: "True"
True
>>>
```
### Cloning, preparing the environment and running the tests
Linux environment.
```bash
git clone https://github.com/kurotom/comicpy.git
cd comicpy
poetry shell
poetry install
. run_tests.sh
```
Raw data
{
"_id": null,
"home_page": "https://github.com/kurotom/comicpy",
"name": "comicpy",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.9",
"maintainer_email": null,
"keywords": "comic, cbz, cbr, manga",
"author": "kurotom",
"author_email": "55354389+kurotom@users.noreply.github.com",
"download_url": "https://files.pythonhosted.org/packages/3f/5d/6a1e55aa6a6dae7731537260ef3df95ed155b65e5f962b24a1e247ce8f68/comicpy-0.1.36.tar.gz",
"platform": null,
"description": "# comicpy\n\nTool to create CBR or CBZ files.\n\nExtracts images from PDF, ZIP, CBR files, generating comic files respecting their original order.\n\n\n> [!Important]\n>> The original files are not altered.\n>\n\n\n## Features\n\n* Convert `PDF` file to `CBR` or `CBZ` files (by default).\n* Convert `RAR` files to `CBR` files.\n* Convert `ZIP` files to `CBZ` files.\n* Scan in given directory and filter `PDF`, `ZIP`, `RAR` files depending on the given extension, convert them into `CBR` or `CBZ` files, generating individual files or consolidated into one.\n* Scan in the given directory and filter `CBR`, `CBZ` files allowing to merge them all into one.\n* Extract `CBR` or `CBZ` files from `RAR` or `ZIP` archives.\n* Support for password protected `RAR` or `ZIP` archives.\n* Convert image directories (*jpeg*, *png*, *jpg*) to `CBR` or `CBZ` files.\n\n\n> [!Important]\n>> 1. For full operation of `comicpy` when using RAR files, you must have available the `rar` command, download and install it from the official site, [**rarlab - rar/unrar command**](https://www.rarlab.com/download.htm).\n>\n>> 2. Some PDF files *contain multiple images on the same page*, which may be *repeated* within the *same file*; converting the PDF file <u>will remove all duplicate images</u>. <u>This is due to the original construction and layout of the source PDF file</u>. Therefore, as a result, there may be fewer or more pages compared to the original PDF file, this does *not necessarily indicate that the work of this tool (**comicpy**) is flawed or faulty*.\n>\n>> Any problem, suggestion, doubt, leave it in [*Issues*](https://github.com/kurotom/comicpy/issues) of the repository.\n>\n\n\n# Installation\n\n```bash\npip install comicpy\n```\n\n# Usage\n\n## CLI - usage\n\nCommand help.\n\n```bash\n$ comicpy -h\n```\n\n### File usage\n\n| Command | Description |\n|-|-|\n| --type f | File. |\n| -p PATH, --path PATH | Path of file. |\n| --motorPDF {pypdf} | PDF library to use. |\n| -c {rar,zip}, --compressor {rar,zip} | Type of compressor to use. |\n| --check | Check the CBR or CBZ files created. |\n| -u {b,kb,mb,gb}, --unit {b,kb,mb,gb} | Unit of measure of data size. Default is \"mb\". |\n| --password PASSWORD | Password of file protected. |\n| --resize {preserve,small,medium,large} | Resize images. |\n| --progress | Shows file in progress. |\n\n```bash\n$ comicpy --type f -p file.PDF --check -u kb\n$\n$ comicpy --type f -p file.rar --check\n$\n$ comicpy --type f -p file.zip --check --password PASS\n$\n$ comicpy --type f -p file.rar --check --resize small\n```\n\n### Directory usage\n\n| Command | Description |\n|-|-|\n| --type d | Directory. |\n| -p PATH, --path PATH | Path of directory. |\n| --filter {pdf,rar,zip,cbr,cbz,images} | Filter files on directory. Default is \"zip\". |\n| --motorPDF {pypdf} | PDF library to use. |\n| -c {rar,zip}, --compressor {rar,zip} | Type of compressor to use. Default is \"zip\".|\n| --check | Check the CBR or CBZ files created. |\n| --join | Join or does not files thath are in the directory. Default is \"False\". |\n| -u {b,kb,mb,gb}, --unit {b,kb,mb,gb} | Unit of measure of data size. Default is \"mb\". |\n| --password PASSWORD | Password of file protected. |\n| --resize {preserve,small,medium,large} | Resize images. |\n| --progress | Shows file in progress. |\n\n\n```bash\n$ comicpy --type d -p rars_dir --filter rar -c rar --check --join -o prefix_final_ --password PASS\n$ for i in $(ls -d Zip_Dir_*/); do\n> comicpy --type d -p \"$i\" --filter zip -c zip --check -o ${i: 0:-1} --join\n> done\n$ comicpy --type d -p rars_dir --filter rar -c rar --check --join -o prefix_final_ --password PASS --resize preserve\n$ comicpy --type d -p Comic_vol1/ --compress zip --filter images --check --progress --join\n```\n\n\n\n## Development - usage\n\n> `path='.'` parameter indicates that files will be written by default to the current directory. It can be changed.\n\n## Single PDF, RAR, ZIP file -> CBZ or CBR\n\n```python\n>>> from comicpy import ComicPy\n>>>\n>>> file = \"fileComic.pdf\"\n>>>\n>>> comic = ComicPy(unit='mb')\n>>>\n>>> metadata = comic.process_pdf(\n... filename=file,\n... compressor='zip'\n... )\n>>>\n>>> print(metadata)\n[{'name': './Converted_comicpy/fileComic/fileComic.cbz', 'size': '193.24 MB'}]\n>>>\n>>> comic.check_integrity(filename=metadata[0]['name'])\nFile \"fileComic.cbz\" is valid?: \"True\"\nTrue\n>>>\n```\n\n## Directory with PDFs, RARs, ZIPs files -> CBZ or CBR\n\n> The `join` parameter indicates whether all found files are merged or treated as individual files.\n\n\n* Example, directory with RAR files - `join=False`\n\n```python\n>>> from comicpy import ComicPy\n>>>\n>>> dir = 'ComicVol1'\n>>>\n>>> comic = ComicPy(unit='GB')\n>>>\n>>> metadata = comic.process_dir(\n... directory_path=dir,\n... extension_filter='rar',\n... compressor='rar',\n... password=None,\n... join=False\n... )\n\n>>> print(metadata)\n[{'name': './Converted_comicpy/ComicVol1/chapter_1.cbr', 'size': '0.03 GB'}, {'name': './Converted_comicpy/ComicVol1/chapter_2.cbr', 'size': '0.02 GB'}]\n>>>\n>>>\n>>> for item in metadata:\n... comic.check_integrity(\n... filename=item['name'],\n... show=True\n... )\n...\nFile \"chapter_1.cbr\" is valid?: \"True\"\nTrue\nFile \"chapter_2.cbr\" is valid?: \"True\"\nTrue\n>>>\n```\n\n\n* Example, directory with RAR files - `join=True`\n\n```python\n>>> from comicpy import ComicPy\n>>>\n>>> dir = 'ComicVol1'\n>>>\n>>> comic = ComicPy(unit='GB')\n>>>\n>>> metadata = comic.process_dir(\n... directory_path=dir,\n... extension_filter='rar',\n... compressor='rar',\n... password=None,\n... join=True\n... )\n>>>\n>>> print(metadata)\n[{'name': './Converted_comicpy/ComicVol1/chapter_1.cbr', 'size': '0.09 GB'}]\n>>>\n>>> for item in metadata:\n... comic.check_integrity(\n... filename=item['name'],\n... show=True\n... )\n...\nFile \"chapter_1.cbr\" is valid?: \"True\"\nTrue\n>>>\n```\n\n### Cloning, preparing the environment and running the tests\n\nLinux environment.\n\n```bash\ngit clone https://github.com/kurotom/comicpy.git\n\ncd comicpy\n\npoetry shell\n\npoetry install\n\n. run_tests.sh\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "Tool to create CBR or CBZ files, supports PDF, ZIP, RAR files.",
"version": "0.1.36",
"project_urls": {
"Bug Tracker": "https://github.com/kurotom/comicpy/issues",
"Homepage": "https://github.com/kurotom/comicpy",
"Repository": "https://github.com/kurotom/comicpy"
},
"split_keywords": [
"comic",
" cbz",
" cbr",
" manga"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "e4e3bd14c2e0d9fc953387356a2a78c8982be9cd44ced22e69bce55fb5a3a9db",
"md5": "1c8e7b4f34ae64ce69282f6f65ffcfc6",
"sha256": "92cb9bf3bf4b284a672921e08bf1efb2b4fbef122e822f827a039efa9eed893e"
},
"downloads": -1,
"filename": "comicpy-0.1.36-py3-none-any.whl",
"has_sig": false,
"md5_digest": "1c8e7b4f34ae64ce69282f6f65ffcfc6",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.9",
"size": 502148,
"upload_time": "2025-03-04T00:31:01",
"upload_time_iso_8601": "2025-03-04T00:31:01.197674Z",
"url": "https://files.pythonhosted.org/packages/e4/e3/bd14c2e0d9fc953387356a2a78c8982be9cd44ced22e69bce55fb5a3a9db/comicpy-0.1.36-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "3f5d6a1e55aa6a6dae7731537260ef3df95ed155b65e5f962b24a1e247ce8f68",
"md5": "6a9956fc52d8f93e877b9dc131ee8a15",
"sha256": "523fd3e83bca7acbb6524fca62815495ca49dcaad3c6e9ae4505eeb21b776514"
},
"downloads": -1,
"filename": "comicpy-0.1.36.tar.gz",
"has_sig": false,
"md5_digest": "6a9956fc52d8f93e877b9dc131ee8a15",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.9",
"size": 492345,
"upload_time": "2025-03-04T00:31:03",
"upload_time_iso_8601": "2025-03-04T00:31:03.111180Z",
"url": "https://files.pythonhosted.org/packages/3f/5d/6a1e55aa6a6dae7731537260ef3df95ed155b65e5f962b24a1e247ce8f68/comicpy-0.1.36.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-03-04 00:31:03",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "kurotom",
"github_project": "comicpy",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "pillow",
"specs": [
[
"==",
"10.4.0"
]
]
},
{
"name": "pycryptodome",
"specs": [
[
"==",
"3.20.0"
]
]
},
{
"name": "pycryptodomex",
"specs": [
[
"==",
"3.20.0"
]
]
},
{
"name": "pypdf",
"specs": [
[
"==",
"4.1.0"
]
]
},
{
"name": "pyzipper",
"specs": [
[
"==",
"0.3.6"
]
]
},
{
"name": "rarfile",
"specs": [
[
"==",
"4.1"
]
]
},
{
"name": "typing-extensions",
"specs": [
[
"==",
"4.7.1"
]
]
}
],
"lcname": "comicpy"
}