Replies: 5 comments 4 replies
-
Supplymentary materialEnvironment:OS: macOS Code:from rapidocr_onnxruntime import RapidOCR
engine = RapidOCR()
image_path = "1.wmf"
with open(image_path, "rb") as f:
img = f.read()
result, elapse_list = engine(img)
print(result)
print(elapse_list) WMF Image:Error:(xxxx) ➜ python git:(main) ✗ python demo.py
Traceback (most recent call last):
File "/Users/xxxx/projects/RapidOCR/python/demo.py", line 19, in <module>
result, elapse_list = engine(img)
File "/Users/xxxx/projects/RapidOCR/python/rapidocr_onnxruntime/main.py", line 79, in __call__
img = self.load_img(img_content)
File "/Users/xxxx/projects/RapidOCR/python/rapidocr_onnxruntime/utils.py", line 125, in __call__
img = self.load_img(img)
File "/Users/xxxx/projects/RapidOCR/python/rapidocr_onnxruntime/utils.py", line 139, in load_img
img = np.array(Image.open(BytesIO(img)))
File "/Users/xxxx/miniconda3/envs/xxxx/lib/python3.10/site-packages/PIL/Image.py", line 696, in __array_interface__
new["data"] = self.tobytes()
File "/Users/xxxx/miniconda3/envs/xxxx/lib/python3.10/site-packages/PIL/Image.py", line 754, in tobytes
self.load()
File "/Users/xxxx/miniconda3/envs/xxxx/lib/python3.10/site-packages/PIL/WmfImagePlugin.py", line 160, in load
return super().load()
File "/Users/xxxx/miniconda3/envs/xxxx/lib/python3.10/site-packages/PIL/ImageFile.py", line 344, in load
raise OSError(msg)
OSError: cannot find loader for this WMF file |
Beta Was this translation helpful? Give feedback.
-
On macOS and Linux, I have temporarily found a better way to read wmf format image files. |
Beta Was this translation helpful? Give feedback.
-
I think currently best way to do is to convert unspported format to pdf files, which is also easier for parsing and embedding. |
Beta Was this translation helpful? Give feedback.
-
I searched and found no suitable tool for converting WMF format images to PDF. |
Beta Was this translation helpful? Give feedback.
-
can install LibreOffice for converting or loading WMF/EMF format. See below |
Beta Was this translation helpful? Give feedback.
-
Looks like RapidOCR uses Pillow to load image. There is a problem with WMF/EMF format which will be used / embedded sometimes in MS Powerpoint and Word documents. When using RapidOCR to scan and recognize these office documents, it will throw out exception that "cannot find loader for this WMF file".
Accoding to Pillow documentation, the full support for WMF/EMF formats are only available in Windows. I understand that it calls Win32 API to get actual loading of WMF format
python-pillow/Pillow#2971
So maybe we can compile from source to get it supported (haven't tried it). But in general, can we use different image loader here? Such as OpenCV, matplotlib, etc...
Thanks
Beta Was this translation helpful? Give feedback.
All reactions