I am trying to read text from tif or tiff image files. These files have multiple pages.
When I print the array i only get true and then no text. However when i use .png files i am able to print the text.
Below is my code.
from PIL import Image, ImageSequence
import pytesseract
from pytesseract import image_to_string
import numpy as np
import cv2
test = Image.open(r'C:\Python\BG36820V1.tiff')
#test1 = Image.open(r'C:\Users\Documents\declaration.png')
testarray = np.array(test)
print(testarray)
print(pytesseract.image_to_string(Image.fromarray(testarray))
This is the out put for the test file:
[[ True True True ... True True True]
[ True True True ... True True True]
[ True True True ... True True True]
...
[ True True True ... True True True]
[ True True True ... True True True]
[ True True True ... True True True]]
However this works fine with the test1.
[[[242 242 242 255]
[242 242 242 255]
[242 242 242 255]
...
[242 242 242 255]
[242 242 242 255]
[242 242 242 255]]
[[182 180 182 255]
[182 180 182 255]
[182 180 182 255]
...
[182 180 182 255]
[182 180 182 255]
[182 180 182 255]]
g Request 4042337300021 submitted sucessfully
x
TYPE
i tried opencv to read tiff files i get format not supported.
How do i get to print the text from the tiff or tif files.
Any suggestions?
Regards, Ren.