Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

In a djvu file, it has two book pages in one djvu page. I would like to split it so that one book page per djvu page. For example,enter image description here

I was wondering if this can be done by some software, preferably command line utilities? Thanks and regards!

PS: This is a file that can be used for test.

share|improve this question
add comment

4 Answers

The following is untested, but in principle it should work (I will test it if I have more time).

You could convert the djvu file for example to jpg's like this:

# djvu -> jpgs converter


# number of pages (392)
while [ $i -ne 392 ]
ddjvu -page=$i -format=pnm 1.djvu $i.pnm
pnmtojpeg $i.pnm > $i.jpg
rm -f $i.pnm
echo "page $i done"
i=`expr $i + 1`

(from http://caree.livejournal.com/74639.html)

Then you could use scantailor to split the pages and produce a new output (consisting of tif files).

Apply in a third step djvubind to that folder and you get your desired djvu file.

share|improve this answer
Thanks! I wonder if it is possible to operate on djvu files directly, without converting to other formats. I knew that the job can be done by converting djvu files to pdf files, and then operate on pdf files and finally convert back to djvu files. –  Tim Dec 6 '11 at 21:38
add comment

There aren't so many tools that can operate directly on DjVu files, compared with other more common formats such as PDF or JPEG. With image manipulation programs, there's the added hurdle that most of these operate on a single image at a time, but the DjVu file contains multiple pages.

One possibility is to go via pdf. With ddjvu from DjVuLibre, a PDF un2up filter, and pdf2djvu:

ddjvu -format=pdf 2up.djvu 2up.pdf
un2up <2up.pdf | pdf2djvu /dev/stdin >1up.djvu

You might be able to cobble up an un2up for djvu inspired by my pdf version using python-djvulibre. I haven't checked how hard that API is to get into.

share|improve this answer
add comment

Here is my complete working script. It needs djvulibre-bin library for ddjvu (decode to tiff format), cjb2 (because i don't know how to directly convert tiff to djvu), djvm (for insertions/deletions of pages in djvu file) tools and imagemagick library for convert (for splitting page and converting to mystical pbm file format) tool. All libraries available through apt-get.


file.djvu --./ddjvu--> bifold tiff --./convert--> single page tiff --./convert--> pbm --./djvm--> out.djvu

Example: djvusplit 3 10 file.djvu which means split pages from 3 to 10.

Complete code:

echo Usage: djvusplit PAGEFROM PAGETO FILE.DJVU

#make temp folder
mkdir ./tmp
cp "$3" ./tmp/
cd tmp

for i in $(seq -w $2 -1 $1) # Descending
    ddjvu -format=tiff -page=$i "$3" t$i.tiff
    convert -crop 2x1@ t$i.tiff t$i-%d.tiff
    convert t$i-0.tiff t$i-0.pbm
    convert t$i-1.tiff t$i-1.pbm
    cjb2 t$i-0.pbm t$i-0.djvu
    cjb2 t$i-1.pbm t$i-1.djvu
    djvm -i t$i-0.djvu t$i-1.djvu 2
    djvm -d $3 $i
    djvm -i $3 t$i-0.djvu $i
    rm ./t*

# total clean
mv $3 ../out.djvu
cd ..
rm -r ./tmp


  1. It works slow because of generating many tiff/pbm/djvu files.
  2. Split page looses any OCR text.

I use this script with some other to maintaining my electronic library. They located here on GitHub.

share|improve this answer
add comment


Hope you find your answer here.

share|improve this answer
Thanks, but the link is to extract some pages from a djvu file into a new djvu file. I would like to split each djvu page into two djvu pages in a djvu file. –  Tim Dec 6 '11 at 19:58
yeah, idea is to extract all the pages as individual from djvu file and then merge the even number of files into single djvu file and repeat this for every 2 files. Finally, merge all the doubly-paged single djvu files into single djvu file. –  Nikhil Mulley Dec 6 '11 at 20:12
I don't quite understand your comment. How do you solve the question in my post? –  Tim Dec 6 '11 at 20:31
I need to get djvu tools installed on my system and will try to give you a work around. –  Nikhil Mulley Dec 6 '11 at 20:39
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.