libheif icon indicating copy to clipboard operation
libheif copied to clipboard

Slow opening of the photo

Open guglovich opened this issue 2 years ago • 5 comments

My iPhone photo opens for about 2s. Other much heavier files open immediately. Will the speed be optimised in the future or is it no longer better?

guglovich avatar Jun 18 '22 16:06 guglovich

Can someone post an image example from iPhone that opens in "2 seconds"?

bigcat88 avatar Jul 05 '22 23:07 bigcat88

Now there are no files nearby, I asked people, but not yet. Found an old benchmark, it was made by me and the author PhotoQt. https://gitlab.com/lspies/photoqt/-/issues/110

guglovich avatar Jul 12 '22 16:07 guglovich

Here are two images in a ZIP file: one in HEIF (slow to open) and the same one converted to JPEG (fast to open). Slow opening comparison.zip

tbertels avatar Jan 17 '23 15:01 tbertels

Same issue here, jpg and CR2 raw are fast, instantaneous, while iphone heif takes about 3 seconds to show and makes browsing my library a real pain.

cvinhaes avatar Apr 04 '23 13:04 cvinhaes

Here are two images in a ZIP file: one in HEIF (slow to open) and the same one converted to JPEG (fast to open). Slow opening comparison.zip


pillow_heif.register_heif_opener()

if __name__ == "__main__":
    pillow_heif.options.DECODE_THREADS = 1
    start_time = time_ns()
    p = "20230117_161524.heic"
    im = Image.open(p)
    im.load()
    print(f"Time: {(time_ns() - start_time) / 1e9}")
    exit(0)

Time: 0.677469

pillow_heif.options.DECODE_THREADS = 6

Time: 0.16587

Apple M2

Note: By default libheif uses 4 threads, afaik.

It can be faster, when libheif will have flag to not rotate image or when someone will make a PR with fast rotation implementation.

bigcat88 avatar Apr 04 '23 13:04 bigcat88