📜 ⬆️ ⬇️

We read DJVU and PDF on a six-inch reader with comfort

There is an opinion that on e-books with e-ink displays, you can comfortably read only text books, where you can set a large font, but pdf and moreover scans in djvu are almost impossible to read, you can break eyes to disassemble small letters on a small display. I hasten to dissuade you, it is quite possible to read such books comfortably.


This is my second e-book and many books have already been read on it, many of them are voluminous, most of which are technical literature that you cannot find in the fb2 format. With the book I bought first, there was a wonderful JaP (Just Another Printer) utility that knew how to cut pdf and djvu into pieces, for even and not even pages you could set your frame, you could also add contrast, and the whole thing saved to the format of my book wolf. For good quality books, for example, purchased or scanned with quality, this was quite enough, but poor quality scans, and there were quite a few of them, the pages jumped on the sheet, the fields were different, so it was necessary to set a border for each page separately.

This state of affairs quickly got bored and I wrote a script that cuts the village in half and cuts off the fields; this greatly simplified the preparation of books for reading. But in different books there was a different font and format of pages, and if some were quite so comfortable to read, then there were books of large format and not very large print, their reading was not so comfortable. Then the idea was born to cut not into two parts, but into three, for the sake of experiment, and the result turned out to be quite different. Visually, the letters became larger due to the fact that they stretched out in length. And although it would seem that having remained the same in width, it would not look that good. But reading, a rather subconscious process, even looking at a very small text, I do not peer at the letters, I glanced briefly and understand its meaning already, the recognition is automatic. And if we are reading a book, and not a separate phrase, then we already in the context of the book and the subconscious know about what information and what words can be found here, which also improves the recognition process. I read the small print as quickly as a large font, if you can see it clearly at all, but it is psychologically more comfortable to read the text with the usual text for ordinary books, so this hack goes off, the subconscious mind is quite capable of recognizing the text, but with large letters I now read it more comfortable.
')
Below is the script code itself, it is quite simple and simple, as it was written mostly for yourself. The most important lines in it are trimming fields, cutting a page into three parts using ImageMagic and sharpening, because after reducing the size of the picture, the sharpness is lost, it is still possible to play with the contrast for the running options. I checked the work of the script on Ubuntu 10.04, for the work ImageMagic, libtiff, pdftk and DjvuLibre must be installed. As practice has shown, djvu is a bit heavy for my reader, but the pdf in-built xPdf reads just to cheer, the speed of turning over in pdf-files larger than 300MB at the level of the same fb2. By the way, about the size, the files turn out to be huge from 100MB to 300 or even more, in principle, with today's flash memory price, this is not so critical. I tried to reduce DPI, but with 16 gradations it becomes noticeable, so I left it as it is, can someone tell me how to reduce the size without noticeable loss in quality, I will be grateful.

#!/bin/bash #    PDF  DJVU       800x600 # :   -in_[pdf|djvu] -out_[pdf|djvu] -img_format_[png|jpg] in_format=$2 out_format=$3 img_format=$4 if [ "$img_format" = "-img_format_png" ]; then img_format=png else img_format=jpg fi mask="*.*" if [ "$in_format" = "-in_djvu" ]; then #   DJVU      TIFF ddjvu -format=tiff $1 1.tiff #   TIFF    tiffsplit 1.tiff rm 1.tiff mask="x*.tif" else #  PDF   pdftk $1 burst mask="pg_*.pdf" fi pages="" #    for p in `ls -1 $mask`; do #    JPG      if [ "$in_format" = "-in_djvu" ]; then convert -colorspace gray -normalize -contrast $p $p.${img_format} else convert -density 300 -colorspace gray -normalize -contrast $p $p.${img_format} fi rm $p p=${p}.${img_format} #     convert -trim +repage $p $p #     convert -gravity North -crop 100%x35% +repage $p 1_$p #     convert -gravity Center -crop 100%x35% +repage $p 2_$p #     convert -gravity South -crop 100%x35% +repage $p 3_$p rm $p #    800600 convert -scale 800x600! 1_$p 1_$p convert -scale 800x600! 2_$p 2_$p convert -scale 800x600! 3_$p 3_$p #   90  convert -rotate 90 1_$p 1_$p convert -rotate 90 2_$p 2_$p convert -rotate 90 3_$p 3_$p #    convert -sharpen 0.01 1_$p 1_$p convert -sharpen 0.01 2_$p 2_$p convert -sharpen 0.01 3_$p 3_$p #    DJVU if [ "$out_format" = "-out_djvu" ]; then #    djvu- c44 -dpi 150 1_$p 1_$p.djvu c44 -dpi 150 2_$p 2_$p.djvu c44 -dpi 150 3_$p 3_$p.djvu #   pages=${pages}' 1_'${p}'.djvu 2_'${p}'.djvu 3_'${p}'.djvu' else convert -define pdf:use-trimbox=true -density 200 1_$p 1_$p.pdf convert -define pdf:use-trimbox=true -density 200 2_$p 2_$p.pdf convert -define pdf:use-trimbox=true -density 200 3_$p 3_$p.pdf #   pages=${pages}' 1_'${p}'.pdf 2_'${p}'.pdf 3_'${p}'.pdf' fi rm 1_$p 2_$p 3_$p done #     if [ "$out_format" = "-out_djvu" ]; then #    DjVu djvm -c out.djvu $pages else #    PDF pdftk $pages cat output out.pdf fi rm $pages 


Actually the result, do not pay attention to the quality of the pictures, Fota on the soap box, without a flash, to eliminate glare. The book is cut in half, borderless:



The book with the pages cut into three parts:



But for example, and a book with pages cut into four parts, for me it is already a little bust:



UPD: The alakond user suggested a way to somewhat reduce the size of the output file. To do this, use PNG format as an intermediate image format instead of Jpeg, added changes to the script to select an intermediate format.

Source: https://habr.com/ru/post/130308/


All Articles