Skip to content

Commit

Permalink
Add avif and heif image format support
Browse files Browse the repository at this point in the history
titusz committed Jan 22, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 0a5500d commit d54996a
Showing 6 changed files with 130 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## Changelog

## 0.6.0 - Unreleased
- Add avif and heif image format support
- Update to Exiv2 0.27.7
- Add Python 3.12 Support
- Add Pydantic v2 Support
2 changes: 2 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
## Changelog

## 0.6.0 - Unreleased
- Add avif and heif image format support
- Update to Exiv2 0.27.7
- Add Python 3.12 Support
- Add Pydantic v2 Support
- Dropped Python 3.8 Support
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
@@ -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__ = [
5 changes: 4 additions & 1 deletion iscc_sdk/mediatype.py
Original file line number Diff line number Diff line change
@@ -198,7 +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 = {
# Text Formats
@@ -244,6 +245,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"},
118 changes: 117 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -59,6 +59,8 @@ pymupdf = "^1.21"
ebookmeta = "^1.2"
python-docx = "^0.8"
typer = {extras = ["all"], version = "^0.9.0"}
pillow-avif-plugin = "^1.4.1"
pillow-heif = "^0.14.0"


[tool.poetry.dev-dependencies]

0 comments on commit d54996a

Please sign in to comment.