About Blog Contact

Images to DJVU book

Sometimes I need to concatenate a bunch of scanned photos of books. I made a tiny script to help me with this task.

# https://superuser.com/questions/519767/convert-serveral-image-files-to-a-single-djvu-file
# Need to apt install djvulibre-bin first
for i in `seq 282`; do # Change it to your own page number!
  echo $i
  # pbm, or PixelBitmap, is a very simple black and white bitmap format with zero compression.
  convert $i.png $i.pbm # Make sure your files are named in such a way!
  # Turn the pbm file into a djvu file 
  cjb2 -lossy $i.pbm $i.djvu # naming due to the fact djvu uses JBIG2 compression.
  pages="$pages $i.djvu"

# Concatenate all the DjVus together!
djvm -c book.djvu  $pages