I want convert a djvu file to six pages, for example,
how to convert a file with 504 pages to 84 files with 6 pages?
There is AFAIK not such a utility that does exactly what you want but you can explode the file by repeatedly using the djvused
utility:
djvused file.djvu -e "select <nr>; save-page-with <filename>"
where <nr>
is the pagenumber and <filename>
the output filename. I have a python utility that does this automatically for all the pages while using incremental filename of the form page_<nr>.djvu
.
After that you can combine multiple files with the djvm
command:
djvm -c output.djvu page01.djvu page02.djvu ... page06.djvu
for each of the combinations of page. The images and associated data (like OCR-ed text) will get in the 84 files. That data is not unpacked and repacked, so the process doesn't lead to any loss of quality.
The following is a minimalistic version of my Python program that calls djvused
to explode the file into individual pages:
#! /usr/bin/env python
import sys
from subprocess import check_output
page_base = 'page_{:03d}.djvu'
file_name = sys.argv[1]
djvused = 'djvused' # r'C:\Program Files\DjVuLibre\djvused.exe'
number_of_pages = int(check_output([djvused, file_name, '-e', 'n']))
for x in range(number_of_pages):
page_name = page_base.format(x)
check_output([djvused, file_name, '-e',
'select {}; save-page-with {}'.format(x+1, page_name)])
It looks like djvu files are essentially layered images, rather than anything textual. If this is in fact the case, getting text out of them will require optical character recognition (and subsequent proofreading) on the way to making an ebook. Those conversions can be problematic to do--there are frequently formatting issues.
That being said, it looks like there's a push-button solution out there called CloudConvert. Can't vouch for the quality of the file you get, but it might be a place to start.