I am working on application to resize the images. It is working fine with image format of jpg, png, jpeg, but its not working as expected to heic files.
Error:
OpenCV(4.4.0) /tmp/pip-req-build-vu_aq9yd/opencv/modules/imgproc/src/color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'
Code snipplet
npimg = np.frombuffer(stream.read(), np.uint8)
img = cv2.cvtColor(cv2.imdecode(npimg, cv2.IMREAD_COLOR), cv2.COLOR_BGR2RGB)
h, w = cls.get_dims(img, dpi)
img = cv2.resize(img, (w, h), interpolation=cv2.INTER_AREA)
return Image.fromarray(img).convert("RGB")
What I found is:
cv2.imdecode(npimg, cv2.IMREAD_COLOR)
returns none.
I am not able to figure out why its not working with heic file. What can be the solution for this issue?
Note:
I had looked through the previous similar issue, but none of them worked for me.