Tool to create CBR or CBZ files, supports PDF, ZIP, RAR files.
Project description
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 toCBR
orCBZ
files (by default). - Convert
RAR
files toCBR
files. - Convert
ZIP
files toCBZ
files. - Scan in given directory and filter
PDF
,ZIP
,RAR
files depending on the given extension, convert them intoCBR
orCBZ
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
orCBZ
files fromRAR
orZIP
archives. - Support for password protected
RAR
orZIP
archives. - Convert image directories (jpeg, png, jpg) to
CBR
orCBZ
files.
[!Important]
- For full operation of
comicpy
when using RAR files, you must have available therar
command, 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.
In continuous development of
comicpy
, 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. |
--motorPDF {pypdf,pymupdf} | 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. |
$ 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,pymupdf} | 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. |
$ 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
>>> 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
>>> from comicpy import ComicPy
>>>
>>> dir = 'ComicVol1'
>>>
>>> comic = ComicPy(unit='GB')
>>>
>>> metadata = comic.process_dir(
... directory_path=dir,
... extention_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,
... extention_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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file comicpy-0.1.33.tar.gz
.
File metadata
- Download URL: comicpy-0.1.33.tar.gz
- Upload date:
- Size: 493.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.11.8 Linux/6.7.11-100.fc38.x86_64
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0f536d6f5974e1b9085400e835b00839ed882736a8d6a365b565a813466d1cb3 |
|
MD5 | 09a38ee4ea45b858cd30373fabfe53a9 |
|
BLAKE2b-256 | 5dc7ac9aa20991e9a1d872f1b3a28069ff73c7b3491a9a5a077d16b81ee54fc0 |
File details
Details for the file comicpy-0.1.33-py3-none-any.whl
.
File metadata
- Download URL: comicpy-0.1.33-py3-none-any.whl
- Upload date:
- Size: 502.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.11.8 Linux/6.7.11-100.fc38.x86_64
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4987985cf1bcc0541cfa892a20c1b5d687e5bdbc927855de2d7f0dd156a9d44d |
|
MD5 | 6957d5d9915e7cc1df5df94a788db8a0 |
|
BLAKE2b-256 | d45e324fd972cdb198e76d10c147caadb2ac03e2e39754c8f00caeaddf43c732 |