Skip to content

Commit b22eaa4

Browse files
authored
Remove Pillow conversion since, it doesn't support all cases
It seems that it supports conversion only between L, RGB and CMYK. https://pillow.readthedocs.io/en/stable/reference/Image.html#PIL.Image.Image.convert Also fixes 287
1 parent 8a5af0d commit b22eaa4

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

src/pytesseract.py

+1-7
Original file line numberDiff line numberDiff line change
@@ -157,19 +157,13 @@ def prepare(image):
157157
if extension not in SUPPORTED_FORMATS:
158158
raise TypeError('Unsupported image format/type')
159159

160-
if not image.mode.startswith(RGB_MODE):
161-
image = image.convert(RGB_MODE)
162-
163160
if 'A' in image.getbands():
164161
# discard and replace the alpha channel with white background
165162
background = Image.new(RGB_MODE, image.size, (255, 255, 255))
166163
background.paste(image, (0, 0), image)
167164
image = background
168165

169166
image.format = extension
170-
if 'format' not in image.info:
171-
image.info['format'] = extension
172-
173167
return image, extension
174168

175169

@@ -183,7 +177,7 @@ def save(image):
183177

184178
image, extension = prepare(image)
185179
input_file_name = f.name + extsep + extension
186-
image.save(input_file_name, **image.info)
180+
image.save(input_file_name, format=image.format)
187181
yield f.name, input_file_name
188182
finally:
189183
cleanup(f.name)

0 commit comments

Comments
 (0)