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
PDFfile toCBRorCBZfiles (by default). - Convert
RARfiles toCBRfiles. - Convert
ZIPfiles toCBZfiles. - Scan in given directory and filter
PDF,ZIP,RARfiles depending on the given extension, convert them intoCBRorCBZfiles, generating individual files or consolidated into one. - Scan in the given directory and filter
CBR,CBZfiles allowing to merge them all into one. - Extract
CBRorCBZfiles fromRARorZIParchives. - Support for password protected
RARorZIParchives. - Convert image directories (jpeg, png, jpg) to
CBRorCBZfiles.
[!Important]
- For full operation of
comicpywhen using RAR files, you must have available therarcommand, download and install it from the official site, rarlab - rar/unrar command.
- Some PDF files contain multiple images on the same page, which may be repeated within the same file; converting the PDF file will remove all duplicate images. This is due to the original construction and layout of the source PDF file. 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 of the repository.
Installation
pip install comicpy
Usage
CLI - usage
Command help.
$ comicpy -h
File usage
| Command | Description |
|---|---|
| --type f | File. |
| -p PATH, --path PATH | Path of file. |
| -c {rar,zip}, --compressor {rar,zip} | Type of compressor to use. Default is "zip". |
| --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. |
| --version | Show comicpy version |
$ comicpy --type f -p file.pdf -u kb --check
$
$ comicpy --type f -p file.rar --check
$
$ comicpy --type f -p file.zip --password PASS --check
$
$ comicpy --type f -p file.rar --resize small --check
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". |
| -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. |
| --version | Show comicpy version |
$ comicpy --type d -p rars_dir --filter rar -c rar --join -o prefix_final_ --password PASS --check
$
$ for i in $(ls -d Zip_Dir_*/); do
> comicpy --type d -p "$i" --filter zip -c zip -o ${i: 0:-1} --join --check
> done
$
$ comicpy --type d -p rars_dir --filter rar -c rar --join -o prefix_final_ --password PASS --resize preserve --check
$
$ comicpy --type d -p Comic_vol1/ --compress zip --filter images --progress --join --check
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
>>> 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
joinparameter indicates whether all found files are merged or treated as individual files.
- Example, directory with RAR files -
join=False
>>> 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
>>> 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.
git clone https://github.com/kurotom/comicpy.git
cd comicpy
poetry shell
poetry install
./run_tests.sh
Metadata
Release files for comicpy 0.1.42
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| comicpy-0.1.42.tar.gz | 492.8 kB | Without provenance | Details for comicpy-0.1.42.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| comicpy-0.1.42-py3-none-any.whl | Python 3 | none | any | Details for comicpy-0.1.42-py3-none-any.whl |
Total release size: 996.2 kB
Release files / comicpy-0.1.42.tar.gz
| Download URL | comicpy-0.1.42.tar.gz |
|---|---|
| Size | 492.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8932dc0a7cf2ab063a570c4e8b3eeb8050afab9d873dfdbff036c3e1bc1b4e59
|
|
BLAKE2b-256 checksum How to use checksums |
c2c3ab9a6c389bd619ca709155b716699f7db8733889fdef8c5eadb9e8be4710
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.2.1 CPython/3.12.5 Linux/6.11.0-1018-azure
|
Release files / comicpy-0.1.42-py3-none-any.whl
| Download URL | comicpy-0.1.42-py3-none-any.whl |
|---|---|
| Size | 503.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1d6e7dfb6f386fef7d84cb200066d14aee901bee42e1d1254e40a7b86ba48392
|
|
BLAKE2b-256 checksum How to use checksums |
0f0345e5974b892e5e8c66ca429bb3d49a34d3542258de8a2f07a96fc82f29f6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.2.1 CPython/3.12.5 Linux/6.11.0-1018-azure
|
Security for comicpy 0.1.42
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.