Tell me more ×
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

3 Answers

http://en.wikisource.org/wiki/Help:DjVu_files#Splitting_DjVu_files

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

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:

#!/bin/sh
# djvu -> jpgs converter

i=1

# number of pages (392)
while [ $i -ne 392 ]
do
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`
done

(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

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

Your Answer

 
discard

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.