I have written two scripts to prepare pictures
for bitonal compression.
One for automatic image manipulation in GIMP and another to control the overall conversion and compression process.
I usually scan my text documents at 300dpi (grayscale), adjust contrast and brightness,
double the size and threshold appropiately.
Then I convert the grayscale image to a bitonal
image.
Doubling the size before thresholding and compression
leads too much better results - in my case.
However the bitonal images render nicer
with DJVIEW on Linux than on Windows with
the commercial viewer. I suppose that DJVIEW
uses gray color tones if the image is not zoomed
1:1. Is this true? Or is it maybe a LCD vs. tube
issue?
I do not know how to assemble mixed documents
(photo+text+background) with djvu command
utilities. I think the process could be automated
for some applications together with GIMP.
A HOW-TO for basic uses cases would be quite
helpful for beginners.
Now the GIMP-script and the Python script
to control the conversion (put in the
public domain by me):
You must adjust the threshold value.
Probably much more :-)
I have written two scripts to prepare pictures
for bitonal compression.
One for automatic image manipulation in GIMP and another to control the overall conversion and compression process.
I usually scan my text documents at 300dpi (grayscale), adjust contrast and brightness,
double the size and threshold appropiately.
Then I convert the grayscale image to a bitonal
image.
Doubling the size before thresholding and compression
leads too much better results - in my case.
However the bitonal images render nicer
with DJVIEW on Linux than on Windows with
the commercial viewer. I suppose that DJVIEW
uses gray color tones if the image is not zoomed
1:1. Is this true? Or is it maybe a LCD vs. tube
issue?
I do not know how to assemble mixed documents
(photo+text+background) with djvu command
utilities. I think the process could be automated
for some applications together with GIMP.
A HOW-TO for basic uses cases would be quite
helpful for beginners.
Now the GIMP-script and the Python script
to control the conversion (put in the
public domain by me):
You must adjust the threshold value.
Probably much more :-)
Enjoy:
doit.scm---------------------------------------
"load image"
(set! image (car (gimp-file-load 1 "in.tif" "in.tif")))
(gimp-image-convert-grayscale image) ;; ()
(set! height (* 2.0 (car (gimp-image-height image))))
(set! width (* 2.0 (car (gimp-image-width image))))
"scale"
(gimp-image-scale image width height)
;;(gimp-image-resize image width height 0 0) ;; ()
;;(gimp-image-get-layers image)
;;(gimp-layer-resize-to-image-size layer)
;;(gimp-layer-scale layer)
;;(gimp-image-scale image width height)
"threshold"
(set! layer (car (gimp-image-get-active-layer image)))
(gimp-threshold layer 220 255)
;;"display"
;;(gimp-display-new image)
"monochrome"
(gimp-image-convert-indexed image 0 3 2 0 0 "")
"save&quit"
(set! drawable (car (gimp-image-active-drawable image)))
(gimp-file-save 1 image drawable "out.png" "out.png" 2) ;; 2
(gimp-quit 1) ;; ()
tiffs2djvu.py---------------------------------------
#!/usr/bin/python
from __future__ import generators
from os import system,unlink,rename
import sys
def tif_to_djvu(tiffName):
# in.tif -> process in gimp -> out.png
rename(tiffName,"in.tif")
try:
print "gimp"
system("gimp -i -b - < /somebin/doit.scm >/dev/null 2>/dev/null")
finally:
rename("in.tif",tiffName)
def main():
files=sys.argv[1:]
main()