This is a simple PowerShell script (with a Bash equivalent) that batch converts .pdf files to .cbz using Ghostscript.
It was created to remedy the Humble Bundle tendency to release graphic novel and comic bundles as .pdf files only. It is written as simply as possible so that anyone can easily check the file and see that it is safe to use.
By default the script converts grayscale pages to 600dpi lossless pngs and colour pages to 400dpi jpegs with 90% compression quality.
Version 0.4 allows users to pass parameters to the script to override the default quality settings.
The parameters are:
-blackres= sets the DPI for black and white pages (default 600);-colourres= sets the DPI for colour pages (default 400);-quality= sets the jpeg compression quality for colour pages (default 90);-forceblackandwhite= Forces black and white conversion for all but the cover page (default $False).
-
You will need to install Ghostscript to process the files.
-
Download the
pdf-cbz-converter.ps1script to a folder on your computer. -
You will need to 'unblock' the script as it is unsigned. To do this, right click on the file, click properties, and then check 'unblock' at the bottom of the menu.
-
Run one of the following in PowerShell:
# Default conversion
C:\PATH_TO_SCRIPT\pdf-cbz-converter.ps1
# Choose custom settings
C:\PATH_TO_SCRIPT\pdf-cbz-converter.ps1 -blackres 600 -colourres 600 -quality 90 -forceblackandwhite $False- A file selection window will appear. Select multiple files using shift or ctrl.
-
Install Ghostscript and
zip(both available via most package managers). -
Run the script with one or more PDF paths:
# Default conversion
./pdf-cbz-converter.sh ./path/to/file.pdf
# Custom settings
./pdf-cbz-converter.sh -b 600 -c 600 -q 90 -f ./path/to/file.pdf ./path/to/another.pdfOptions mirror the PowerShell parameters:
-b|--blackressets DPI for black and white pages (default 600)-c|--colourressets DPI for colour pages (default 400)-q|--qualitysets JPEG compression quality for colour pages (default 90)-f|--forceblackandwhiteforces black and white conversion for all but the cover page-t|--testskips CBZ packaging so you can inspect the generated images in the temporary folder
Each PDF generates a temporary folder named after the file, which is zipped to .cbz in the same directory before the folder is removed.
Earlier versions of the script are available in the archive folder.