mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
Merge branch 'develop' into feature/load-api
This commit is contained in:
commit
6a38b35ea0
20 changed files with 866 additions and 359 deletions
|
|
@ -420,11 +420,14 @@ def get_review_info_by_layer_name(channel_names):
|
|||
channel = last_part[0].upper()
|
||||
rgba_by_layer_name[layer_name][channel] = channel_name
|
||||
|
||||
# Put empty layer to the beginning of the list
|
||||
# Put empty layer or 'rgba' to the beginning of the list
|
||||
# - if input has R, G, B, A channels they should be used for review
|
||||
if "" in layer_names_order:
|
||||
layer_names_order.remove("")
|
||||
layer_names_order.insert(0, "")
|
||||
# NOTE They are iterated in reversed order because they're inserted to
|
||||
# the beginning of 'layer_names_order' -> last added will be first.
|
||||
for name in reversed(["", "rgba"]):
|
||||
if name in layer_names_order:
|
||||
layer_names_order.remove(name)
|
||||
layer_names_order.insert(0, name)
|
||||
|
||||
output = []
|
||||
for layer_name in layer_names_order:
|
||||
|
|
@ -1519,12 +1522,27 @@ def get_media_mime_type(filepath: str) -> Optional[str]:
|
|||
Optional[str]: Mime type or None if is unknown mime type.
|
||||
|
||||
"""
|
||||
# The implementation is identical or better with ayon_api >=1.1.0,
|
||||
# which is used in AYON launcher >=1.3.0.
|
||||
# NOTE Remove safe import when AYON launcher >=1.2.0.
|
||||
try:
|
||||
from ayon_api.utils import (
|
||||
get_media_mime_type_for_content as _ayon_api_func
|
||||
)
|
||||
except ImportError:
|
||||
_ayon_api_func = None
|
||||
|
||||
if not filepath or not os.path.exists(filepath):
|
||||
return None
|
||||
|
||||
with open(filepath, "rb") as stream:
|
||||
content = stream.read()
|
||||
|
||||
if _ayon_api_func is not None:
|
||||
mime_type = _ayon_api_func(content)
|
||||
if mime_type is not None:
|
||||
return mime_type
|
||||
|
||||
content_len = len(content)
|
||||
# Pre-validation (largest definition check)
|
||||
# - hopefully there cannot be media defined in less than 12 bytes
|
||||
|
|
@ -1551,11 +1569,13 @@ def get_media_mime_type(filepath: str) -> Optional[str]:
|
|||
if b'xmlns="http://www.w3.org/2000/svg"' in content:
|
||||
return "image/svg+xml"
|
||||
|
||||
# JPEG, JFIF or Exif
|
||||
if (
|
||||
content[0:4] == b"\xff\xd8\xff\xdb"
|
||||
or content[6:10] in (b"JFIF", b"Exif")
|
||||
):
|
||||
# JPEG
|
||||
# - [0:2] is constant b"\xff\xd8"
|
||||
# (ref. https://www.file-recovery.com/jpg-signature-format.htm)
|
||||
# - [2:4] Marker identifier b"\xff{?}"
|
||||
# (ref. https://www.disktuna.com/list-of-jpeg-markers/)
|
||||
# NOTE: File ends with b"\xff\xd9"
|
||||
if content[0:3] == b"\xff\xd8\xff":
|
||||
return "image/jpeg"
|
||||
|
||||
# Webp
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue