Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
skandalfo opened this issue Nov 3, 2021 · 1 comment
Assignees

Comments

@skandalfo
Copy link

skandalfo commented Nov 3, 2021

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.

@lilohuang lilohuang self-assigned this Nov 3, 2021
@lilohuang
Copy link
Owner

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

lilohuang added a commit that referenced this issue Nov 6, 2021
scale_with_quality() returns empty data if decoding the image to be scaled triggers a warning. #53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants