Recorded:
import jpeg4py
path = template_image[0]
im = jpeg4py.JPEG(path).decode()
"""
Note: template_image is ndarray type
"""
1. Error Message:
\jpeg4py._py.JPEGRuntimeError: tjDecompressHeader2() failed with error -1 and error string Not a JPEG
2. Reason: Problem with data type
>>> type(path)
<class 'numpy.str_'>
>>> # Although equal
>>> str(path) == path
True
>>> # But they are different types
>>> type(str(path))
<class 'str'>
3. Solution:
import jpeg4py
path = template_image[0]
im = jpeg4py.JPEG(str(path)).decode()
"""
Note: path-->str(path)
Type from <class 'numpy.str_'> modify to <class 'str'>
"""
Read More:
- [Solved] Python Image Library fails with message “decoder JPEG not available” – PIL
- tensorflow2.3 InvalidArgumentError: jpeg::Uncompress failed [How to Solve]
- [Solved] AttributeError: module ‘PIL.Image‘ has no attribute ‘open‘
- [Solved] supervisor Error: /usr/local/lib/python2.7/dist-packages/pkg_resources/py2_warn.py:22: UserWarning: Setuptools will stop working on Python 2
- [Solved] SyntaxError: (unicode error) ‘unicodeescape‘ codec can‘t decode bytes in position 6-7: malformed
- Python Error: SyntaxError: (unicode error) ‘unicodeescape‘ codec can‘t decode bytes in position 2-3:
- Python 3.7 Error: AttributeError: ‘str‘ object has no attribute ‘decode‘ [How to Solve]
- How to Solve Pytorch DataLoader Loading Error: UnicodeDecodeError: ‘utf-8‘ codec can‘t decode byte 0xe5 in position 1023
- [Solved] main.py: error: the following arguments are required:
- [Solved] AttributeError: ‘str‘ object has no attribute ‘decode‘
- [Solved] original_keras_version = f.attrs[‘keras_version‘].decode(‘utf8‘)
- SyntaxError: (unicode error) ‘unicodeescape‘ codec can‘t decode bytes in position 2-3: truncated \UX
- [Solved] SyntaxError: (unicode error) ‘utf-8’ codec can’t decode byte 0xbe in position 0
- Djangorestframework-simplejwt: ‘str‘ object has no attribute ‘decode‘ [Solved]
- Linux Fatal Python error: Py_Initialize Unable to get the locale encoding
- [Solved] AttributeError: ‘str‘ object has no attribute ‘decode‘
- [Solved] git review Error: UnicodeDecodeError: ‘gbk‘ codec can‘t decode
- SyntaxError: (unicode error) ‘unicodeescape‘ codec can‘t decode bytes in position 2-3: truncated \UX
- Decode PUP data Error when reading radar data [How to Solve]
- Django CSV file Error: UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xb5 in position 0: invalid start