uploadcare / heif-image-plugin Goto Github PK
View Code? Open in Web Editor NEWThis project forked from ciotto/pyheif-pillow-opener
Simple HEIF (.heic and .avif) images plugin for Pillow base on pyhief library.
License: MIT License
This project forked from ciotto/pyheif-pillow-opener
Simple HEIF (.heic and .avif) images plugin for Pillow base on pyhief library.
License: MIT License
I have been migrating away from https://github.com/ciotto/pyheif-pillow-opener and got an error that .heic
extension was not supported. After looking into it, it seems pillow-opener registered the extensions. I think it would be good to add it to this plugin as well:
Image.register_extensions(HeifImageFile.format, ['.heic', '.heif'])
Does not work with Pillow 10.1. The attribute ImageFile.mode can no longer be set directly.
This is the same issue as: imageio/imageio#1044
I can get it work by monkeypatching the HeifImageFile._open function, changing the line:
self.mode = heif_file.mode
to
self._mode = heif_file.mode
but would be good to have a proper fix.
import HeifImagePlugin
from PIL import Image, ImageOps
with Image.open('some-heic-file.heic') as image:
# raises exception here
File "/opt/venvs/python/lib/python3.11/site-packages/PIL/Image.py", line 3284, in open
im = _open_core(fp, filename, prefix, formats)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/venvs/python/lib/python3.11/site-packages/PIL/Image.py", line 3270, in _open_core
im = factory(fp, filename)
^^^^^^^^^^^^^^^^^^^^^
File "/opt/venvs/python/lib/python3.11/site-packages/PIL/ImageFile.py", line 117, in __init__
self._open()
File "/opt/venvs/python/lib/python3.11/site-packages/HeifImagePlugin.py", line 117, in _open
self.mode = heif_file.mode
^^^^^^^^^
AttributeError: property 'mode' of 'HeifImageFile' object has no setter
using the plugin with Pillow (used by sigal, static image gallery generator ) it crashes:
Collecting albums, done.
Sorting albums [####################################] 100%
Sorting media [####################################] 100%
Collecting files [####################################] 100%
Processing files [------------------------------------] 0/2
Traceback (most recent call last):
File "/home/simon/python_virt_sigal/env/bin/sigal", line 8, in
sys.exit(main())
File "/home/simon/python_virt_sigal/env/lib/python3.9/site-packages/click/core.py", line 1128, in call
return self.main(*args, **kwargs)
File "/home/simon/python_virt_sigal/env/lib/python3.9/site-packages/click/core.py", line 1053, in main
rv = self.invoke(ctx)
File "/home/simon/python_virt_sigal/env/lib/python3.9/site-packages/click/core.py", line 1659, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/simon/python_virt_sigal/env/lib/python3.9/site-packages/click/core.py", line 1395, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/simon/python_virt_sigal/env/lib/python3.9/site-packages/click/core.py", line 754, in invoke
return __callback(*args, **kwargs)
File "/home/simon/python_virt_sigal/env/lib/python3.9/site-packages/sigal/init.py", line 157, in build
gal.build(force=force)
File "/home/simon/python_virt_sigal/env/lib/python3.9/site-packages/sigal/gallery.py", line 756, in build
for status in self.pool.imap_unordered(worker, media_list):
File "/usr/lib/python3.9/multiprocessing/pool.py", line 870, in next
raise value
File "/usr/lib/python3.9/multiprocessing/pool.py", line 537, in _handle_tasks
put(task)
File "/usr/lib/python3.9/multiprocessing/connection.py", line 211, in send
self._send_bytes(_ForkingPickler.dumps(obj))
File "/usr/lib/python3.9/multiprocessing/reduction.py", line 51, in dumps
cls(buf, protocol).dump(obj)
TypeError: cannot pickle 'module' object
i do generate image gallery with sigal, which uses Pillow
i do generate image gallery with sigal, which uses Pillow
Pillow can handle heif images with this plugin and the gallery generates
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.