Skip to content

Commit

Permalink
Add avif and heif image format support
Browse files Browse the repository at this point in the history
  • Loading branch information
titusz committed Dec 3, 2023
1 parent 854ff52 commit 1d7bf80
Show file tree
Hide file tree
Showing 4 changed files with 184 additions and 70 deletions.
4 changes: 4 additions & 0 deletions iscc_sdk/image.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""*Image handling module*."""
import pillow_avif
import base64
import io
import shutil
Expand All @@ -12,6 +13,9 @@
from loguru import logger as log
from PIL import Image, ImageEnhance, ImageChops, ImageOps
import iscc_sdk as idk
from pillow_heif import register_heif_opener

register_heif_opener()


__all__ = [
Expand Down
4 changes: 4 additions & 0 deletions iscc_sdk/mediatype.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ def mediatype_to_mode(mime_type):
"application/vnd.openxmlformats-officedocument.wordprocessingml.document", ".docx"
)
mimetypes.add_type("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", ".xlsx")
mimetypes.add_type("image/heif", ".heif")
mimetypes.add_type("image/avif", ".avif")


SUPPORTED_MEDIATYPES = {
Expand Down Expand Up @@ -244,6 +246,8 @@ def mediatype_to_mode(mime_type):
"image/tiff": {"mode": "image", "ext": "tif"},
"image/vnd.adobe.photoshop": {"mode": "image", "ext": "psd"},
"application/postscript": {"mode": "image", "ext": "eps"},
"image/avif": {"mode": "image", "ext": "avif"},
"image/heif": {"mode": "image", "ext": "heif"},
# Audio Formats
"audio/mpeg": {"mode": "audio", "ext": "mp3"},
"audio/wav": {"mode": "audio", "ext": "wav"},
Expand Down
Loading

0 comments on commit 1d7bf80

Please sign in to comment.