Monday, April 22, 2013

Kindle, and comics - but sympathy is not [Ubuntu / Debian tips] - dobreprogramy

last weekend came to me pod?amany friend who is a big fan of comic books. A few days earlier purchased the e-book reader Kindle, which planned to read stories hatched. Everything would be different colors if the Kindle from Amazon handled the format CBR (comic book archive), and not just with PDF.

Sam CBR format is nothing but a RAR archive containing image files PNG or JPEG . In addition to the files. Cbr files can also be found. Cbz (ZIP archive), as well. Cbt (TAR).

Okay – some theory behind us ;)

With the knowledge that the only archive we can easily extract and convert these images to the desired portable document format. Our intentions will need several existent tools.

  • pdftk – tool for modifying PDF files.
  • sam2p – tool for converting raster images to PDF
  • unzip – zip decompressor
  • unrar – rar archive decompressor

Ubuntu / Debian have to execute the following command:
sudo apt-get install unzip sam2p pdftk unrar

When all the tools are installed correctly we can start to write a script that will remodel our unfortunate. cbr’a.
#! / bin / bash file_in = $ 1 # file cbr (z) (t) is designed to convert FILE_OUT = "$ {1}. pdf" # create a random directory name in the / tmp / DIR = `mktemp`; rm-fr $ DIR; mkdir $ DIR; # Unpack archwiwum echo "Unpack archwiwum comic book ..." if file "$ file_in" | grep-iq rar, then unrar e-inul-s "$ file_in" $ DIR elif file "$ file_in" | grep-iq zip then unzip-qq "$ file_in"-d $ DIR elif file "$ file_in" | grep-iq tar, then tar-xvf "$ file_in" $ DIR fi # create PDFA echo "create PDFA ..." # find all files with desired extensions and sort them for i in `find $ DIR | grep-i '. jpg $ | . bmp $ | . png $ | . tiff $ ' | sort`; to sam2p j: quiet-c: dct $ and $ DIR / `basename $ {i%. jpg}. pdf`, done # combination of individual PDF files into one. echo "We are uniting pdfs ..." pdftk $ DIR / * . pdf cat output "$ FILE_OUT"

After running the script if you have to wait … This can take quite a long time – it depends on what hardware launched conversions and how many “pages” consisted of a comic book.

About as it presents the Kindlu. Photo taken from Google’s, because I could not swing a buddy went out too.

For me, the quality is not too cool – also depends on the book, the original is in color or black and white. You can always play around with the contrast JPEGów, which can increase the outline on e-ink readers.

No comments:

Post a Comment