-
Notifications
You must be signed in to change notification settings - Fork 18
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
Performance degrades for multi-image encode, is there support for multi-threaded encoder? #317
Comments
From your code I see it's not a tiled image, you're just creating a file with 4 images, right? Support for tiled image encoding was only added in the latest libheif version |
Yes, because I don't know how to create a tiled image from a large resolution image, I did not find the parameter Settings related to tiled in the code, so I manually cut the large resolution image into several 512*512 small pictures, and then stack these small pictures together and use encode_image interface for encode. In addition, In the latest 0.21.0 update log, libheif version was updated to 1.19.5, which is also the latest version of libheif. Is it because some features in libheif have not been integrated? |
Even though the latest version is with I'll take a look in a few days to see how hard it is to add (how much code is needed for this) support for tiled images. If anyone want implement this himself, I'll gladly accept PR for this |
I think it will be enought if you set the autotile param for encoder to true as default. Then it will decide tilling automatically based on image resolution. |
To do this, we need to completely rework image reading, not just writing. To read images, use the following functions: After that, we can implement only tile encoding into an image. Since But I would still wait until Pillow starts supporting more than |
Describe the bug
When I want to compress a large resolution image, I want to cut the large resolution image into multiple sub-images of small resolution, such as 512*512, pillow_heif supports the compression of multiple sub-images, but the performance will be greatly reduced compared with the direct compression of large-resolution images. I noticed that multi-graph compression in the code seems to be serial for encode one by one,
pillow_heif/pillow_heif/heif.py
Line 604 in 55a3d39
Steps/Code to Reproduce
and here is my test image
1-input.zip
Expected Results
The performance of multiple sub-images encode should be no lower than that of a single full-resolution graph directly encode
Actual Results
The performance of multi-subimage encode is more than 4 times lower than that of direct encode for a single full-resolution image
multi-subimage encode cost: 1.2968940734863281s
single full-resolution encode cost: 5.515080690383911s
Versions
The text was updated successfully, but these errors were encountered: