Skip to content

Instantly share code, notes, and snippets.

@BigRoy
Created October 25, 2023 12:40
Show Gist options
  • Save BigRoy/c5621daf72b76e7e96323624a19f2662 to your computer and use it in GitHub Desktop.
Save BigRoy/c5621daf72b76e7e96323624a19f2662 to your computer and use it in GitHub Desktop.
OpenPype get thumbnail for an entity
from openpype.pipeline.thumbnail import get_thumbnail_binary
from openpype.client import get_thumbnail_id_from_source, get_thumbnail
def get_entity_thumbnail(project_name, entity_id, entity_type):
thumbnail_id = get_thumbnail_id_from_source(project_name, entity_type, entity_id)
if not thumbnail_id:
return
thumbnail_entity = get_thumbnail(project_name, thumbnail_id, entity_type, entity_id)
if not thumbnail_entity:
return
return get_thumbnail_binary(thumbnail_entity, thumbnail_entity["type"])
def get_entity_thumbnail_from_doc(project_name, entity_doc):
entity_type = entity_doc["type"]
entity_id = entity_id["_id"]
return get_entity_thumbnail(project_name, entity_id, entity_type)
def get_version_thumbnail(project_name, version_id):
"""Return thumbnail binary data from version id"""
entity_type = "version"
return get_entity_thumbnail(project_name,
entity_id=version_id,
entity_type="version")
project_name = "test"
version_id = "6358115dafb2f0665c5932f0"
data = get_version_thumbnail(project_name, version_id)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment