lilohuang/PyTurboJPEG

`scale_with_quality()` returns empty data if decoding the image to be scaled triggers a warning.

skandalfo opened this issue · 1 comments

I was debugging why my mjpg_streamer images wouldn't show in Home Assistant's preview cards. Turns out HA is using PyTurboJPEG to try to rescale down the source image to a better fit to the card size, but my camera is producing some flaky (m)jpeg output that triggers these warnings:

/srv/homeassistant/lib/python3.9/site-packages/turbojpeg.py:867: UserWarning: Corrupt JPEG data: 1 extraneous bytes before marker 0xd4

It turns out the return in this line needs to be removed:

if status != 0:
    self.__report_error(handle)
    return

__report_error() will already raise an exception when an actual error has occurred, so no return is necessary. When what we had was a warning only, the return will prevent the code from proceeding.

I tested this by modifying my own installation to remove the line and see that I now have this camera's preview in the HA card.

I will remove the unnecessary "return" this week. Thanks for your feedback.