Scripts updated on 28 February 2009
You may (re-)use these scripts under the terms of the CC-BY License.
This script will scan for ZIP- and RAR-files (including CBZ- and CBR-files) inside the current folder and inside subfolders (but not subsubfolders), optimize the images found in the archives and put them into PDFs inside a "CYBOOK Converted Manga", "SONY Converted Manga" or "ILIAD Converted Manga" folder (the title and content of the PDF will be the same as the archive).
If there already is a PDF inside the Converted Manga folder with the same name as the archive, the file will be skipped, e.g. if the file "CYBOOK Converted Manga/Megatokyo/MT_Chapter01.pdf" exists, the file "Megatokyo/MT_Chapter01.zip" will be skipped.
The script has the ability to halve double pages (two pages of a manga in one image). By default it's disabled, to activate it open the script and set "HalveDoublePages" to "1". The default is to use the standard manga orientation right-to-left, if you rename a folder to have the characters LTR at the very end (e.g. "Megatokyo LTR"), left-to-right orientation will be used. Of course the script will only halve images if the width is greater than the height and the size is greater than the size of the final resolution.
The script has also the ability to rotate double pages. By default it's disabled, to activate it open the script and set "RotateDoublePages" to "1" for 90° counter-clockwise rotation or "2" for 90° clockwise rotation. This does not work if halving of double pages is activated. Of course the script will only rotate images if the width is greater than the height and the size is greater than the size of the final resolution.
Requirements:
Bash compatible shell, ImageMagick, GIMP, libtiff (aka libtiff-tools), unzip, unrar.
ImageMagick version 6.3.2 or newer is needed for the -extent option to work properly, see posts at the end of the first page of this thread for further informations.
How to install it:
Move the colors4.gpl, colors8.gpl and colors16.gpl files into your GIMP palettes folder (usually "~/.gimp-2.4/palettes").
Move the batch-unsharp-mask-4.scm, batch-unsharp-mask-8.scm and batch-unsharp-mask-16.scm into your GIMP scripts folder (usually "~/.gimp-2.4/scripts")
Move the bash scripts that you need somewhere meaningful (e.g. "/usr/bin" or your Nautilus scripts folder "~/.gnome2/nautilus-scripts").
Note:
As you might have guessed there are three versions of this script, optimised for the Cybook (600x800, 4 colors), Sony Reader (570x760, 8 colors) and the Iliad (768x1024, 16 colors).
For the image optimization trimming will be used, if you don't want trimming, search for and remove "-fuzz "15%" -trim +repage".
The images will be sharpened and dithered using a GIMP script, as this gives better results than the ImageMagick functions.
Known issues:
- Will not work with sub-sub-sub-directories inside an archive (you'll get an error message)
- Only works with *.png, *.jpg and *.gif images (can be changed easily)
Changelog:
4.5.2 Support for CBZ- and CBR-files added.
Changed the order of the tiff2pdf command as it gave errors on a Mac. [
link]
Removed some unnecessary lines of code.
4.5.1 Fixed a small bug that produced errors with filenames that begin with "-".
4.5 – Added the option to rotate double pages 90° counter-clockwise or clockwise
4.4 – Changed the the default dpi to 83 on the Cybook to allow zooming with the new firmware.
Added the option to change the dpi setting (at the top of the script), the default setting for Sony Reader is set to 166 and for the iLiad to 160. This should conform to 100% zoom. Please inform me if a different default setting would be better.
4.3 – The script will write to the file error.log if it encounters errors.
Added the option to stop the script from exiting on errors.
Check if all necessary programs are installed before running the script.
4.2 – Set the image density to 166dpi (Cybook, Reader) or 160dpi (iLiad). Has probably no effect on viewing with the Cybook and Sony Reader, but now the PDFs will correctly view with Evince and Xpdf too (haven't tested them with Adobe Reader).
4.1 – Fixed the internal name of the 8 color palette