Click here for more info on this script, including samples.

MAN PAGE - image2text

 


NAME

image2text - image to text converter


SYNOPSIS

image2text [options]

        -r              reverse colours
        -p              preserve ratio (used with -H and -W)
        -d threshold    rgb value to consider white/black
        -h height       resize height by this amount
        -w width        resize width by this amount
        -H pixels       resize height to this many pixels
        -W pixels       resize width to this many pixels
        -i imagefile    png image file
        -t textfile     text file
        -v              verbose output


DESCRIPTION

image2text converts a png or jpeg image into a text file similar to the image. If the image is not already black and white, it attempts to convert the image to black and white. It can also resize the image.


EXAMPLES

convert image.png to text in text.txt file

        image2text -i image.png -t text.txt

convert image.png to text in text.txt file after resizing height by 80%

        image2text -i image.png -t text.txt -h.8

convert image.png to text in text.txt file after resizing height by 40% and resizing width by 40% (this will produce image similar to previous sample but have as big)

        image2text -i image.png -t text.txt -h.4 -w.5

convert image.png to text in text.txt file after resizing height to 89 pixels and preserving ratio of width to height, then resizing height to 80% of 89, and converting the image to b&w based on a threshold of 50

        image2text -i image.png -t text.txt -H89 -p -h.8 -d50

a character of text is higher than it is wide, unlike a pixel which has the same height as width, so you will want to scale the height of the image in relation to the width. i've found that a ratio of .8:1 works well, hence the ``-h.8'' and ``-w.5 -h.4'' used above.


AUTHOR

frisco@blackant.net