User talk:Inductiveload/Scripts/Universal batch image to DJVU converter/Windows

From Wikisource
Jump to navigation Jump to search

Thanks for the script! There area a couple missing parentheses in print commands in the script which give syntax errors (line 98(?) and 100+ IIRC). After fixing that I was able to batch convert tiff images into a djvu file with the exception of non-bitonal (color) tiff images. Each such image gives an error "tiff image is not bitonal" in cjb2.cpp, followed by "failed to open img-djvu-comverter-temp.djvu" error given by DjvuDocEditor.cpp. Any suggestions? N1of2 (talk) 07:25, 9 January 2012 (UTC)

From the print synatx problem, it sounds like you are using Python 3? This is a Python 2.x script, so be careful when using 3 as it is utterly untested (plus I haven't used or updated the Windows version in ages).

Could you please post the full command you are using, as well as the stacktrace generated when the program terminates at this error. Thanks, Inductiveloadtalk/contribs 20:57, 9 January 2012 (UTC)

Ok I uninstalled Python 3 and gave a shot to Python 2.7. I have no experience with Python so stacktrace isn't easy for me to do... This is what I get in the cmd window though, basically the same errors as with the corrected Python 3 script (the first 2 files are the color tiff files btw):
      C:\>python -i "c:\book" -o "c:\out\b.djvu" -d 
Processing: c:\book\Book ( 0001.tif
*** Tiff image is not bitonal
*** (..\..\..\tools\cjb2.cpp:756)
*** [1-11711] Failed to open 'IMG-DJVU-CONVERTER-TEMP.djvu': No such file or directory.
*** (..\..\..\libdjvu\DjVuDocEditor.cpp:858)
Processing: c:\book\Book ( 0002.tif
*** Tiff image is not bitonal
*** (..\..\..\tools\cjb2.cpp:756)
*** [1-11711] Failed to open 'IMG-DJVU-CONVERTER-TEMP.djvu': No such file or directory.
*** (..\..\..\libdjvu\DjVuDocEditor.cpp:858)
Processing: c:\book\Book ( 0003.tif
Processing: c:\book\Book ( 0004.tif
Processing: c:\book\Book ( 0005.tif
Processing: c:\book\Book ( 0006.tif
Deleting temporary DJVU file.
All files converted and collated successfully
So the output djvu file completely excludes any color tiff files that were in the input folder. If I use color files in .ppm format though the script works well and includes them in the djvu output file. N1of2 (talk) 03:48, 10 January 2012 (UTC)
Try removing the "not" from "elif not self.opts.bitonal and (ext == '.tiff' or ext=='.tif'):" (line 158). I am unable to test this change now, so it is just a guess. Inductiveloadtalk/contribs 09:03, 11 January 2012 (UTC)
Intersting... it works now by apparently converting all .tif images to .ppm :) It is a much longer process and the final djvu file is huge (bigger than the adobe version), so it ain't pretty :) I guess if the script could first try to use cjb2 and only if this results in an error it should convert that image to ppm. That should work perfectly but I don't have enough knowledge yet to modify the script. N1of2 (talk) 18:01, 12 January 2012 (UTC)
       C:\>python -i "c:\out" -o "c:\out\b.djvu" -d
Processing: c:\out\Book ( 0001.tif
['C:\\Program Files\\ImageMagick-6.7.4-Q16\\convert.exe', 'c:\\out\\Book ( 0001.tif', 'c:\\IMG-DJVU-CONVERTER-TEMP.ppm']
Processing: c:\out\Book ( 0002.tif
['C:\\Program Files\\ImageMagick-6.7.4-Q16\\convert.exe', 'c:\\out\\Book ( 0002.tif', 'c:\\IMG-DJVU-CONVERTER-TEMP.ppm']
Processing: c:\out\Book ( 0003.tif
['C:\\Program Files\\ImageMagick-6.7.4-Q16\\convert.exe', 'c:\\out\\Book ( 0003.tif', 'c:\\IMG-DJVU-CONVERTER-TEMP.ppm']
... Deleting temporary DJVU file. All files converted and collated successfully
This script is no longer used or maintained by me (though I will update that fix). I recommend using pyGrabber instead (it does basically the same conversions, but also lets you adjust settings such as quality (so you can reduce filesize) via a GUI and do OCR on it). Howwever, it does have a lot of dependencies (wsPython, tesseract, etc). Feel free to hack on this script if you want and publish new versions. Otherwise, try pyGrabber and leave bug reports or feature requests at the sourceforge tracker page and help requests on the forum page. Cheers, Inductiveloadtalk/contribs 19:00, 13 January 2012 (UTC)
Thanks for the pyGrabber link, I will check it out. The original script is working well as long as you don't use color tiff images. The modified script works on both color and bitonal tiff images (it converts all tiff files into ppm files) but it is useless since it makes HUGE djvu files which defies the purpose of djvu :) Maybe both versions should be posted with such an explanation :) Cheers, N1of2 (talk) 19:17, 13 January 2012 (UTC)