Comments on Creating DjVu Documents Linux HOWTO
Creating DjVu Documents Linux HOWTO This document explains some of the uses of djvulibre implementation of DjVu for creating quality DjVu documents in linux. DjVu format features bitmap document compression and hypertext structure. It is used by numerous web sites all around the world for storing and distributing digital documents including scanned documents and high-resolution pictures. One of the advantages of DjVu files is that they are notably small, often smaller than PDF or JPEG files with the same content. This makes DjVu a helpful tool for digitizing books and journals, especially scientific ones.
3 Comment(s)
Comments
A Extremley good job, on showing people on how to impliment this class.
Here some improvements to the bash script to convert .jpg to .djvu file (any2djvu-low) , only on management of main folder to process and final extension of the djvu file:
#!/bin/sh
#
# FromJpegToBitonal.sh
# requires: anytopnm, ppmtopgm, pgmtopbm and cjb2
# Based on any2djvu-low script from: https://www.howtoforge.com/creating_djvu_documents_on_linux
# Modified by J. Rivera Pineda , xtecuan at gmail dot com
# Site: http://gente.debian.org.sv/~xtecuan/FromJpegToBitonal/
#$1 --- Path to Process
#$2 --- Extension like *.JPG or *.PNG etc
PBASEPATH=$1
if [ -d $PBASEPATH ]
then
if [ -z `which anytopnm` -o -z `which ppmtopgm` -o -z `which pgmtopbm`\
-o -z `which cjb2` ]; then
usage
echo "Error: anytopnm, ppmtopgm, pgmtopbm and cjb2 are needed"
echo
exit 1
fi
shopt -s extglob
DEFMASK="*.JPG"
DPI=300
DEFAULT_PROC_DIR=JPGs
# uncomment the following line to compile a bundled DjVu document
#OUTFILE="#0-bw.djvu"
function usage() {
echo
echo "usage:"
echo
echo "$0 [\"REGEXP\"]"
echo " converts single pages with the default mask $DEFMASK (or REGEXP if provided)"
echo " in the current directory to single-page black and white djvu documents"
# uncomment the following line to compile a bundled DjVu document
# echo " and bundles them as a djvu file $OUTFILE"
echo
}
if [ -n "$2" ]; then
MASK=$2
else
MASK=$DEFMASK
fi
#
if [ ! -d ${PBASEPATH}/${DEFAULT_PROC_DIR} ]
then
echo "Making ${PBASEPATH}/${DEFAULT_PROC_DIR}"
mkdir ${PBASEPATH}/${DEFAULT_PROC_DIR}
fi
for i in ${PBASEPATH}/$MASK; do
newName=`basename $i ${MASK:1}`
if [ ! -e $i ]; then
usage
echo "Error: current directory must contain files with the mask $MASK"
echo
exit 1
fi
if [ ! -e ${newName}.djvu ]; then
echo "Current Processing $i"
anytopnm ${i} | ppmtopgm | pgmtopbm -value 0.499 > ${PBASEPATH}/${newName}.pbm
# in netpbm >= 10.23 the above line can be replaced with the following:
# anytopnm $i | ppmtopgm | pamditherbw -value 0.499 > $.pbm
cjb2 -dpi $DPI ${PBASEPATH}/${newName}.pbm ${PBASEPATH}/${newName}.djvu
rm -f ${PBASEPATH}/${newName}.pbm
echo "Moving $i to ${PBASEPATH}/${DEFAULT_PROC_DIR}/"
mv $i ${PBASEPATH}/${DEFAULT_PROC_DIR}/
fi
done
echo "Process ........[Done]"
# uncomment the following line to compile a bundled DjVu document
#djvm -c $OUTFILE $MASK.djvu
else
echo " ${PBASEPATH} does not exists"
fi
The complete code:
http://gente.debian.org.sv/~xtecuan/FromJpegToBitonal/0.1.1/FromJpegToBitonal.tar.bz2
I created djvu from b/w tiff or jpeg
#!/usr/bin/perl -w # # pic2djvu # vadim likhota, 2006 my $i = 0; my @cmds = qw[ djvm -c output.djvu ]; foreach ( <*.*> ) { if (/(.*)\.jpg$/ ){ print "$_\n"; system("cpaldjvu", $1.'.jpg', $1.'.djvu'); # or # system("c44", '-crcbfull', $1.'.jpg', $1.'.djvu'); $i++; push @cmds, $1.'.djvu'; } if (/(.*)\.pnm$/ ){ print "$_\n"; system("c44 $1.pnm $1.djvu"); $i++; push @cmds, $1.'.djvu'; } elsif (/(.*)\.tif$/ ) { print "$_\n"; system("cjb2", $1.'.tif', $1.'.djvu'); # for set 300 dpi need writed before prev.string #system("tiffset", '-s 296 2', $1.'tiff'); #system("tiffset", '-s 282 300.0', $1.'tiff'); #system("tiffset", '-s 283 300.0', $1.'tiff'); # or #system("cjb2", '-dpi', '300', '-losslevel', '100', $1.'.tiff', $1.'.djvu'); $i++; push @cmds, $1.'.djvu'; } } print "$i files renamed\n"; system(@cmds); print "\n$cmds[2] created";