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

Unable to load Samsungs 200MP Images #328

Open
UHive opened this issue Jan 19, 2025 · 2 comments
Open

Unable to load Samsungs 200MP Images #328

UHive opened this issue Jan 19, 2025 · 2 comments
Labels
bug Something isn't working enhancement New feature or request

Comments

@UHive
Copy link

UHive commented Jan 19, 2025

Describe why it is important and where it will be useful

The latest version of the library cannot load certain valid images taken by the Samsun S24 Ultra camera when taken in the 200MP mode

Describe your proposed solution

Increase the security pixels and memory limits to compensate

Describe alternatives you've considered, if relevant

No response

Additional context

As I am using pi_heif with Pillow, I was able to by pass the pixels limit by declaring PIL.Image.MAX_IMAGE_PIXELS = None However, I am unable to bypass the memory security limit and the library keeps throwing this error whenever I try loading one of my S24 Ultra 200MP photos

Traceback (most recent call last):
  File "E:\Git\TestingHeicConversion\lambda.py", line 41, in <module>
    thumbnails = thumbnail_generator.generate_thumbnails(image)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\Git\TestingHeicConversion\thumbnail_generator.py", line 136, in generate_thumbnails
    resized = self.resize_image(image, dimensions)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\Git\TestingHeicConversion\thumbnail_generator.py", line 67, in resize_image
    return image.resize(new_size, Image.Resampling.LANCZOS)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\Git\TestingHeicConversion\.venv\Lib\site-packages\PIL\Image.py", line 2336, in resize
    self.load()
  File "E:\Git\TestingHeicConversion\.venv\Lib\site-packages\pi_heif\as_plugin.py", line 61, in load
    data = frame_heif.data  # Size of Image can change during decoding
           ^^^^^^^^^^^^^^^
  File "E:\Git\TestingHeicConversion\.venv\Lib\site-packages\pi_heif\heif.py", line 63, in data
    self.load()
  File "E:\Git\TestingHeicConversion\.venv\Lib\site-packages\pi_heif\heif.py", line 114, in load
    self._data = self._c_image.data
                 ^^^^^^^^^^^^^^^^^^
RuntimeError: Memory allocation error: Security limit exceeded: Allocating 599270415 exceeds the security limit of 536870912 bytes

Here is a sample photo for reference: https://drive.google.com/file/d/1O25UO4vms1I4kbauexx0gJ8gtCgWkHFk/view?usp=sharing

@bigcat88
Copy link
Owner

bigcat88 commented Jan 19, 2025

Need to add support for security limits libeheif API for this.

Thanks for reporting this, I'll try to find some time soon to do it.

P.S.: Can I add this photo to the test set of images for this repository?

@bigcat88 bigcat88 added bug Something isn't working enhancement New feature or request labels Jan 19, 2025
@UHive
Copy link
Author

UHive commented Jan 19, 2025

Need to add support for security limits libeheif API for this.

Thanks for reporting this, I'll try to find some time soon to do it.

P.S.: Can I add this photo to the test set of images for this repository?

Yes its a test photo, you may add it to your samples

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants