7

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?

3

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)])
  • Which version of Python is it? Please add it to your answer. Do you have any project with this issue on GitHub where can I join? I am also interested in the issue Epub-DjVu-Python. – Stilgar Dragonclaw Oct 1 '18 at 2:58
  • It should work with Python 2.6+ and Python 3.3+. I have all my (public) projects on bitbucket, and I would have to see if I can publish (more) djvu related code (currently I think only the DjVu code included in Calibre) was put in the public domain. Write me an email if you want to persue anything specific, chatting via comments here is a bit limited. – Anthon Oct 1 '18 at 5:42
  • Ok, I'll look at it. Thx – Stilgar Dragonclaw Oct 1 '18 at 11:38
0

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.

  • scanned ebooks are often image based and non-textual, to get the pages out of them they do not need to be converted to text first, you just have to extract the relevant pages and their attached image(s), without conversion (which, you correctly indicate, can involve formatting issues). Cloudconvert will not do that for you at all – Anthon Feb 15 '14 at 7:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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