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

silent crash on wrong array shape #57

Closed
aqc-carlodri opened this issue Jan 3, 2022 · 1 comment
Closed

silent crash on wrong array shape #57

aqc-carlodri opened this issue Jan 3, 2022 · 1 comment
Assignees

Comments

@aqc-carlodri
Copy link

If I try to encode an image with missing components, the python interpreter silently exits with no message/exception.

See this example code:

from numpy import uint8, zeros
from turbojpeg import TJPF_RGB, TJSAMP_420, TurboJPEG

jpeg = TurboJPEG()

image = zeros((1024, 4096), dtype=uint8)

print("Entering store...")

with open("test.jpg", "wb") as f:
    jpeg_encoded = jpeg.encode(
        image,
        pixel_format=TJPF_RGB,
        quality=95,
        jpeg_subsample=TJSAMP_420,
    )
    f.write(jpeg_encoded)

print("Exiting store (this never gets printed)...")

Conversely, if I say image = zeros((1024, 4096, 3), dtype=uint8), the script completes normally.

Issue appears with both pyturbojpeg 1.6.3 and 1.6.4, on Windows 10x64.

I would expect to see an exception raised in this case.

Thank you for your work on this great wrapper library, and happy new year!

@lilohuang lilohuang self-assigned this Jan 5, 2022
lilohuang added a commit that referenced this issue Jan 8, 2022
1. Improved encode() error handling on wrong array shape (silent crash on wrong array shape #57)
2. Added an extra turbojpeg default path for Mac OS
@aqc-carlodri
Copy link
Author

thank you for the quick solution!

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