Convert manga/comic files(zip, epub, etc.) or directory containing image files (jpg, png, etc.) to PDF.
Project description
manga2pdf
📖 Overview
This Python script is specifically designed to convert manga and comic files, including various formats such as zip, epub, and directories containing image files, to PDF format.
The resulting PDF files are optimized to resemble Japanese manga in terms of page layout and direction. By default, the script uses a "TwoPageRight" page layout that displays two pages side-by-side for a spread view, and a "R2L" (right-to-left) reading direction that is commonly used in Japanese manga.
🔧 Requirements
The script uses the Python libraries img2pdf and pikepdf to do the conversion.
Moreover, it uses lxml to read the EPUB files, rarfile to read the RAR archive files, py7zr to read .7z and .cb7 archive files, numpy for image processing, Pillow for image manipulation, i18nice[YAML] for internationalization, and tkface for enhanced GUI features.
It requires the installation of these packages in order to work properly.
📜 Third-party Licenses
This project uses the following third-party libraries:
- py7zr - GNU Lesser General Public License v2.1
- img2pdf - Apache License 2.0
- pikepdf - Mozilla Public License 2.0
- lxml - BSD License
- rarfile - ISC License
- numpy - BSD License
- Pillow - HPND License
- i18nice - MIT License
- tkface - MIT License
⚠️ Important Notes
- This script can only handle DRM-free fixed-layout EPUB files.
- Please ensure that the image files you input are named in numerical order according to their page sequence. For example,
page_01.jpg,page_02.jpg,page_03.jpg, and so on, or001.jpg,002.jpg,003.jpg, and so on. This will ensure that the pages are converted and compiled in the correct order.
🚀 Usage
This script can take input in the form of zip, cbz, rar, cbr, 7z, cb7, tar, cbt, epub files or directories containing images (jpg, jpeg, png, gif, bmp) of manga or comic pages.
The program can be executed from the command line with the following options:
- The
input_pathargument represents the path to the input file. To execute the Python script correctly, specify theinput_pathargument as the path to the input file containing manga or comic images in any of the supported formats, such aszip,cbz,rar,cbr,7z,cb7,tar,cbt,epub, or a directory containing images in formats such asjpg,jpeg,png,gif, orbmp. - The
output_pathargument is the path to the output PDF file. To use the script, simply run the Python script with the path to the input file or directory as the argument. If the--outputoption is not specified, the output file name will be automatically generated based on the name of the input file or directory. - The
pagelayoutparameter can take in the following values:SinglePage-> Single page displayOneColumn-> Enable scrollingTwoPageLeft-> Spread viewTwoColumnLeft-> Spread view with scrolling- (default)
TwoPageRight-> Separate Cover, Spread View TwoColumnRight-> Separate Cover, Scrolling Spread View
- The
pagemodeparameter can take in the following values:- (default)
UseNone-> Neither document outline nor thumbnail images visible UseOutlines-> Document outline visibleUseThumbs-> Thumbnail images visibleFullScreen-> Full-screen modeUseOC-> Optional content group panel visibleUseAttachments-> Attachments panel visible
- (default)
- The
directionparameter can take in the following values:L2R-> Left Binding- (default)
R2L-> Right Binding
By default, the page layout is set to TwoPageRight and the reading direction to R2L, which are suitable for Japanese manga.
The -j or --jpeg option converts images to JPEG format before including them in the output PDF file, resulting in a smaller file size. Similarly, the -g or --grayscale option can be used to convert images to grayscale and reduce the size of the resulting PDF file. The program outputs the converted image in the specified format and compresses the PDF file accordingly.
The --version option displays the version information and exits.
💭 Note
- When the original image is already in the JPEG format, using the
-jor--jpegoption will have no effect. Similarly, if the original image is already grayscale, using the-gor--grayscaleoption will have no effect. Also, if none of these options are used, the resulting PDF file will not be compressed.
There is a possibility that the script may not be able to handle files in unexpected formats correctly, which may result in errors or unexpected output.
📦 Installation
Installing from PyPI
To install the latest version of the package from PyPI, run the following command:
$ pip install manga2pdf
Installing directly from the Git repository
To install the package directly from the Git repository, run the following command:
$ pip install git+https://github.com/mashu3/manga2pdf.git
Installing by cloning the Git repository
To install the package by cloning the Git repository, follow these steps:
$ git clone https://github.com/mashu3/manga2pdf.git
$ cd manga2pdf/
$ pip install .
💭 Note
- It is recommended to install the package from PyPI, but if you want to try out the latest changes, you can install it from the Git repository.
- This project uses
pyproject.tomlfor package configuration, which is the modern standard for Python packaging.
🎯 Examples
- To convert
my_manga.ziptomy_manga.pdfusing the default settings:
$ manga2pdf my_manga.zip
- To convert
my_manga.epubtomy_manga_spread.pdfwith a spread view and right binding:
$ manga2pdf my_manga.epub -o my_manga_spread.pdf
- To convert
my_comic.epubtomy_comic.pdfwith a TwoPage view and left binding:
$ manga2pdf my_comic.epub -o my_comic.pdf -p TwoPageLeft -d L2R
🖥️ GUI
To launch the graphical user interface:
$ manga2pdf -gui
The interface is available in multiple languages, including English, Japanese, German, Spanish, French, and Chinese (Simplified/Traditional). All settings that can be specified via the command line are available. Please note that translations other than English and Japanese are generated by AI.
The GUI uses tkface, a Tkinter extension library developed specifically to address the limitations encountered while creating manga2pdf's GUI. This library provides:
- Enhanced Date Selection: Modern calendar widgets with multilingual support
- Improved Message Boxes: Centered dialogs with better styling
- DPI Awareness: Automatic scaling for high-resolution displays on Windows
The GUI is currently under development and additional features are planned for future updates.
👨💻 Author
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file manga2pdf-0.3.1.tar.gz.
File metadata
- Download URL: manga2pdf-0.3.1.tar.gz
- Upload date:
- Size: 25.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4b32d7836c51f036658f49351b9ca8c26a6a5ebc05d4bc50bef072a17f28f68c
|
|
| MD5 |
407c39f043327b781888550d5297b84e
|
|
| BLAKE2b-256 |
7482367efa7e628d9d91de94dcdc7cfae9bcde8f7459e270c4d2f30eb0088336
|
File details
Details for the file manga2pdf-0.3.1-py3-none-any.whl.
File metadata
- Download URL: manga2pdf-0.3.1-py3-none-any.whl
- Upload date:
- Size: 28.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bc37c8e088563811c7f36cedd0b9b6961a4b55e879db15a76d08b2dec6cf4f89
|
|
| MD5 |
cb4ee2a4c797f7363d56b586c93dec08
|
|
| BLAKE2b-256 |
6724a52801a428e1a11f41e33c112b5ac5f62afa1bc95045ea25bd1b609efb4e
|