2014. március 16.

DJVU extract images

A useful link:
http://askubuntu.com/questions/46233/converting-djvu-to-pdf

Another useful link: http://unix.stackexchange.com/questions/20592/extract-several-pages-from-a-djvu-file
http://kheyali.blogspot.hu/2011/08/in-order-to-convert-djvu-file-into.html

And another: http://en.wikisource.org/wiki/Help:DjVu_files#DjVu_to_Images


Extract images from DJVU:
DDJVU
The easiest way to do this is probably by extracting to multipage tiff
Than split tiff file with tiffsplit: http://manpages.ubuntu.com/manpages/hardy/man1/tiffsplit.1.html
Than convert to anything useful.
Except that did not work for the file I had...

Okay, so the second way is the script way. Copy the script, paste it to an empty text file. Give it the extension .sh and give it permission to execute as program. Put it in a directory with all the djvu-s you want to extract and run in terminal.

#!/bin/bash
#Ubuntu 10.04 Lucid Lynx

#Put this script file in a directory with all the djvu-s you want to extract and run it in terminal.
#All the DJVU-s in this folder will be extracted to PNM-s.

### Select files to process
#defining the filelist
filelist=(`find -iname '*.djvu' | sort`)
#counting the files in the filelist
element_count=${#filelist[*]}
echo "alltogether $element_count djvu will be processed"

#process only 1 file at a time:
counter=1
echo "processing file:"
for i in "${filelist[@]}"
do
echo -ne "$element_count/$counter"\\r

#Get the number of pages from input file
pagecount=`djvused -e n $i`
#Set a filelist for the pages
 for (( filelist=1; filelist<=$pagecount; filelist+=1 ))
 do
 #Extract with DDJVU
 ddjvu -format=pnm -page=$filelist $i file_$counter.page_$filelist.pnm
 #Or use DjvuPs to extract PS from DJVU the same way:
 #djvups -page=$filelist $i file_$counter.page_$filelist.ps
 done
let "counter = $counter + 1"
done

echo DONE.

Nincsenek megjegyzések: