mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 12:54:40 +01:00
ExtractThumbnail uses AYON settings
This commit is contained in:
parent
b390a7f3b5
commit
8331c90fcf
3 changed files with 32 additions and 36 deletions
|
|
@ -1385,23 +1385,26 @@ def _get_image_dimensions(application, input_path, log):
|
|||
|
||||
def convert_color_values(application, color_value):
|
||||
"""Get color mapping for ffmpeg and oiiotool.
|
||||
|
||||
Args:
|
||||
application (str): Application for which command should be created.
|
||||
color_value (list[int]): List of 8bit int values for RGBA.
|
||||
color_value (tuple[int, int, int, float]): List of 8bit int values
|
||||
for RGBA.
|
||||
|
||||
Returns:
|
||||
str: ffmpeg returns hex string, oiiotool is string with floats.
|
||||
|
||||
"""
|
||||
red, green, blue, alpha = color_value
|
||||
|
||||
if application == "ffmpeg":
|
||||
return "{0:0>2X}{1:0>2X}{2:0>2X}@{3}".format(
|
||||
red, green, blue, (alpha / 255.0)
|
||||
red, green, blue, alpha
|
||||
)
|
||||
elif application == "oiiotool":
|
||||
red = float(red / 255)
|
||||
green = float(green / 255)
|
||||
blue = float(blue / 255)
|
||||
alpha = float(alpha / 255)
|
||||
|
||||
return "{0:.3f},{1:.3f},{2:.3f},{3:.3f}".format(
|
||||
red, green, blue, alpha)
|
||||
|
|
|
|||
|
|
@ -42,15 +42,27 @@ class ExtractThumbnail(pyblish.api.InstancePlugin):
|
|||
|
||||
integrate_thumbnail = False
|
||||
target_size = {
|
||||
"type": "resize",
|
||||
"width": 1920,
|
||||
"height": 1080
|
||||
"type": "source",
|
||||
"resize": {
|
||||
"width": 1920,
|
||||
"height": 1080
|
||||
}
|
||||
}
|
||||
background_color = None
|
||||
background_color = (0, 0, 0, 0.0)
|
||||
duration_split = 0.5
|
||||
# attribute presets from settings
|
||||
oiiotool_defaults = None
|
||||
ffmpeg_args = None
|
||||
oiiotool_defaults = {
|
||||
"type": "colorspace",
|
||||
"colorspace": "color_picking",
|
||||
"display_and_view": {
|
||||
"display": "default",
|
||||
"view": "sRGB"
|
||||
}
|
||||
}
|
||||
ffmpeg_args = {
|
||||
"input": [],
|
||||
"output": []
|
||||
}
|
||||
product_names = []
|
||||
|
||||
def process(self, instance):
|
||||
|
|
@ -369,7 +381,6 @@ class ExtractThumbnail(pyblish.api.InstancePlugin):
|
|||
|
||||
repre_display = colorspace_data.get("display")
|
||||
repre_view = colorspace_data.get("view")
|
||||
oiio_default_type = None
|
||||
oiio_default_display = None
|
||||
oiio_default_view = None
|
||||
oiio_default_colorspace = None
|
||||
|
|
@ -387,11 +398,12 @@ class ExtractThumbnail(pyblish.api.InstancePlugin):
|
|||
# oiiotool_defaults
|
||||
elif self.oiiotool_defaults:
|
||||
oiio_default_type = self.oiiotool_defaults["type"]
|
||||
if "colorspace" in oiio_default_type:
|
||||
if "colorspace" == oiio_default_type:
|
||||
oiio_default_colorspace = self.oiiotool_defaults["colorspace"]
|
||||
else:
|
||||
oiio_default_display = self.oiiotool_defaults["display"]
|
||||
oiio_default_view = self.oiiotool_defaults["view"]
|
||||
display_and_view = self.oiiotool_defaults["display_and_view"]
|
||||
oiio_default_display = display_and_view["display"]
|
||||
oiio_default_view = display_and_view["view"]
|
||||
|
||||
try:
|
||||
convert_colorspace(
|
||||
|
|
@ -507,11 +519,12 @@ class ExtractThumbnail(pyblish.api.InstancePlugin):
|
|||
input_path,
|
||||
):
|
||||
# get settings
|
||||
if self.target_size.get("type") == "source":
|
||||
if self.target_size["type"] == "source":
|
||||
return []
|
||||
|
||||
target_width = self.target_size["width"]
|
||||
target_height = self.target_size["height"]
|
||||
resize = self.target_size["resize"]
|
||||
target_width = resize["width"]
|
||||
target_height = resize["height"]
|
||||
|
||||
# form arg string per application
|
||||
return get_rescaled_command_arguments(
|
||||
|
|
|
|||
|
|
@ -406,26 +406,6 @@ def _convert_global_project_settings(ayon_settings, output, default_settings):
|
|||
# Publish conversion
|
||||
ayon_publish = ayon_core["publish"]
|
||||
|
||||
# ExtractThumbnail plugin
|
||||
ayon_extract_thumbnail = ayon_publish["ExtractThumbnail"]
|
||||
# fix display and view at oiio defaults
|
||||
ayon_default_oiio = copy.deepcopy(
|
||||
ayon_extract_thumbnail["oiiotool_defaults"])
|
||||
display_and_view = ayon_default_oiio.pop("display_and_view")
|
||||
ayon_default_oiio["display"] = display_and_view["display"]
|
||||
ayon_default_oiio["view"] = display_and_view["view"]
|
||||
ayon_extract_thumbnail["oiiotool_defaults"] = ayon_default_oiio
|
||||
# fix target size
|
||||
ayon_default_resize = copy.deepcopy(ayon_extract_thumbnail["target_size"])
|
||||
resize = ayon_default_resize.pop("resize")
|
||||
ayon_default_resize["width"] = resize["width"]
|
||||
ayon_default_resize["height"] = resize["height"]
|
||||
ayon_extract_thumbnail["target_size"] = ayon_default_resize
|
||||
# fix background color
|
||||
ayon_extract_thumbnail["background_color"] = _convert_color(
|
||||
ayon_extract_thumbnail["background_color"]
|
||||
)
|
||||
|
||||
# Project root settings - json string to dict
|
||||
ayon_core["project_environments"] = json.loads(
|
||||
ayon_core["project_environments"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue