Kevin Hu commited on
Commit
ae761d0
·
1 Parent(s): 85d3c0e

Fix t_ocr.py for PNG image. (#4625)

Browse files

### What problem does this PR solve?
#4586

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)

Files changed (1) hide show
  1. deepdoc/vision/__init__.py +5 -1
deepdoc/vision/__init__.py CHANGED
@@ -13,6 +13,7 @@
13
  # See the License for the specific language governing permissions and
14
  # limitations under the License.
15
  #
 
16
 
17
  import pdfplumber
18
 
@@ -48,7 +49,10 @@ def init_in_out(args):
48
  pdf_pages(fnm)
49
  return
50
  try:
51
- images.append(Image.open(fnm))
 
 
 
52
  outputs.append(os.path.split(fnm)[-1])
53
  except Exception:
54
  traceback.print_exc()
 
13
  # See the License for the specific language governing permissions and
14
  # limitations under the License.
15
  #
16
+ import io
17
 
18
  import pdfplumber
19
 
 
49
  pdf_pages(fnm)
50
  return
51
  try:
52
+ fp = open(fnm, 'rb')
53
+ binary = fp.read()
54
+ fp.close()
55
+ images.append(Image.open(io.BytesIO(binary)).convert('RGB'))
56
  outputs.append(os.path.split(fnm)[-1])
57
  except Exception:
58
  traceback.print_exc()