GithubHelp home page GithubHelp logo

uploadcare / heif-image-plugin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ciotto/pyheif-pillow-opener

8.0 8.0 2.0 5.99 MB

Simple HEIF (.heic and .avif) images plugin for Pillow base on pyhief library.

License: MIT License

Makefile 5.82% Python 90.93% Dockerfile 3.25%

heif-image-plugin's People

Contributors

ciotto avatar homm avatar hpoul avatar mikhail-iurkov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

heif-image-plugin's Issues

Register heic/heif extensions

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:

https://github.com/ciotto/pyheif-pillow-opener/blob/5cf38718bcfb07edb9ac56e0a6dc13ff7b4e9830/pyheif_pillow_opener/__init__.py#L84-L88

Image.register_extensions(HeifImageFile.format, ['.heic', '.heif'])

Does not work with Pillow 10.1, ImageFile.mode can no longer be set directly

Describe the bug

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.

Steps to reproduce

import HeifImagePlugin
from PIL import Image, ImageOps

with Image.open('some-heic-file.heic') as image:
    # raises exception here

Code / screenshots

  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

Environment

  • Library version: heif-image-plugin==0.6.0
  • Language/framework version: Python 3.11.5
  • OS version: CentOS 7.9

using the plugin with Pillow (used by sigal, static image gallery generator ) it crashes:

Describe the bug

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

Expected behavior

Pillow can handle heif images with this plugin and the gallery generates

Code / screenshots

grafik
grafik

Environment

  • Library version:
  • Language/framework version:
  • OS version:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.