Thursday, December 18, 2008

Creating DJVU files

I wanted to create a DJVU file from some photocopies (TIFF)

I found some nice tutorials at

http://www.howtoforge.com/creating_djvu_documents_on_linux
http://en.wikisource.org/wiki/Wikisource:How_to_create_a_DJVU_file
http://en.wikisource.org/wiki/Wikisource:How_to_create_a_DJVU_file

Two incredible tools:
http://gscan2pdf.sourceforge.net/
http://unpaper.berlios.de/

My final code was
To rotate and crop all the tiff files:
$ mogrify -rotate 90 *.tiff
$
mogrify -crop 3600x2448+600x0 *.tiff

And then the following script:

#!/bin/bash

shopt -s extglob

MASK="*.tiff"

for i in $MASK; do
if [ ! -e $i.djvu ]; then
echo "$i"
tifftopnm $i > $i.ppm
# unpaper --layout double --output-pages 1 $i.ppm x_$i.ppm
cpaldjvu -verbose -bgwhite -colors 2 $i.ppm $i.djvu
# rm x.ppm $i.ppm
fi
done

# compile a bundled DjVu document
djvm -c book.djvu $MASK.djvu

To make the OCR, use the service in the page
http://any2djvu.djvuzone.org/

No comments: