Django Admin add support for HEIC for ImageField

1.1k views Asked by At

please has someone experience with adding support of new image formats to the Django Admin module? I want to use this one called pyheif-pillow-opener pyheif-pillow-opener for HEIC support. It should be registered, but I am not sure where exactly. I tried to install that module and then in Django Admin upload an image to ImageField, but still, I am getting a message:

Upload a valid image. The file you uploaded was either not an image or a corrupted image.

EDIT - Solution:

There is only need to add to a used Django applications admin.py file these lines of code:

from pyheif_pillow_opener import register_heif_opener

register_heif_opener()
1

There are 1 answers

0
Alexander Piskun On

Another solution(add it to admin.py as TS suggest):

try:
    from pillow_heif import HeifImagePlugin
except ImportError:
    HeifImagePlugin = None # here you can log a warning