{"id":9377,"library":"types-opencolorio","title":"Python Stubs for PyOpenColorIO","description":"types-opencolorio provides static type checking stubs for PyOpenColorIO, the Python bindings for OpenColorIO (OCIO). OCIO is a complete color management solution for motion picture production, emphasizing visual effects and computer animation. This stub package enhances IDE support and enables tools like MyPy for type validation of PyOpenColorIO code. It closely follows the versioning of the main OpenColorIO library, which typically has annual releases around September.","status":"active","version":"2.4.2.0","language":"python","source_language":"en","source_url":"https://github.com/AcademySoftwareFoundation/OpenColorIO","tags":["type-stubs","color-management","vfx","animation","post-production","ocio","opencolorio","mypy"],"install":[{"cmd":"pip install types-opencolorio","lang":"bash","label":"Install stubs"},{"cmd":"pip install opencolorio","lang":"bash","label":"Install runtime (required)"}],"dependencies":[{"reason":"Provides the actual runtime functionality; types-opencolorio only contains type hints.","package":"opencolorio","optional":false}],"imports":[{"wrong":"import PyOpenColorIO-stubs as OCIO","symbol":"PyOpenColorIO","correct":"import PyOpenColorIO-stubs as OCIO"}],"quickstart":{"code":"import PyOpenColorIO as OCIO\nimport os\n\n# For a runnable example, we'll try to get the current config.\n# In a real setup, you'd likely set the OCIO environment variable\n# to point to an OCIO config file, e.g., os.environ['OCIO'] = '/path/to/my_config.ocio'\n# For this example, we'll assume a default or simple config if OCIO is not set.\n\ntry:\n    config = OCIO.GetCurrentConfig()\n    print(\"Successfully loaded OCIO config.\")\nexcept OCIO.Exception as e:\n    print(f\"Could not load OCIO config: {e}. Attempting to create a minimal default config.\")\n    # Create a minimal config for demonstration if none is found\n    config = OCIO.Config.Create()\n    config.setFileFormatVersion(OCIO.Constants.OCIO_FILE_FORMAT_VERSION_2_0)\n    linear_cs = OCIO.ColorSpace.Create()\n    linear_cs.setName(\"linear\")\n    linear_cs.setFamily(\"linear\")\n    linear_cs.setIsData(False)\n    config.addColorSpace(linear_cs)\n    \n    srgb_cs = OCIO.ColorSpace.Create()\n    srgb_cs.setName(\"sRGB\")\n    srgb_cs.setFamily(\"display\")\n    srgb_cs.setIsData(False)\n    srgb_to_linear = OCIO.BuiltinTransform.Create(OCIO.BuiltinTransformRegistry.ACES_CG_TO_ACES2065_1)\n    srgb_to_linear.setDirection(OCIO.TransformDirection.INVERSE_TRANSFORM)\n    srgb_cs.setTransform(srgb_to_linear, OCIO.TransformDirection.FROM_REFERENCE)\n    config.addColorSpace(srgb_cs)\n    \n    config.setDefaultWorkingSpaceName(\"linear\")\n    config.setRole(OCIO.ROLE_SCENE_LINEAR, \"linear\")\n    config.setRole(OCIO.ROLE_COLOR_PICKING, \"sRGB\")\n    config.setRole(OCIO.ROLE_DISPLAY, \"sRGB\")\n\n\n# Define source and destination color spaces\nsource_colorspace = \"sRGB\"\ndestination_colorspace = \"linear\"\n\n# Ensure the color spaces exist in the config\nif config.getColorSpace(source_colorspace) is None:\n    print(f\"Error: Source colorspace '{source_colorspace}' not found in config.\")\n    exit(1)\nif config.getColorSpace(destination_colorspace) is None:\n    print(f\"Error: Destination colorspace '{destination_colorspace}' not found in config.\")\n    exit(1)\n\n# Get a Processor to perform the color transformation\nprocessor = config.getProcessor(OCIO.ColorSpaceTransform(src=source_colorspace, dst=destination_colorspace))\n\n# Create an image buffer (e.g., a single pixel, RGB float values 0-1)\n# Example sRGB value (mid-gray)\ninput_pixel = [0.218, 0.218, 0.218, 1.0] # R, G, B, A\n\n# Create a working buffer (CPU processor operates on this)\n# OCIO expects a contiguous flat array of pixel data.\n# For a single pixel, it's [R, G, B, A]\noutput_pixel_data = list(input_pixel)\n\n# Apply the transformation\n# CPUProcessor handles float arrays directly\ncpu_processor = processor.getCPUProcessor()\ncpu_processor.applyRGB(output_pixel_data)\n\nprint(f\"Input (sRGB): {input_pixel}\")\nprint(f\"Output (linear): {output_pixel_data[:3]} (alpha: {output_pixel_data[3]})\")","lang":"python","description":"This quickstart demonstrates how to load an OpenColorIO configuration and perform a basic color space transformation using the Python bindings. It first attempts to load an existing configuration (e.g., via the `OCIO` environment variable) and falls back to creating a minimal in-memory configuration if none is found. It then converts a sample sRGB pixel value to a linear color space using a `Processor`."},"warnings":[{"fix":"Review the OpenColorIO v2 migration guides. Update configuration files to include new roles and verify clamping behavior. Adapt Python code to the new GPU rendering API if used.","message":"OpenColorIO v2 introduced significant API changes compared to v1, including a re-engineered GPU renderer, modified clamping behavior for transforms, and new requirements for interchange roles (`aces_interchange`, `cie_xyz_d65_interchange`) for inter-config conversions.","severity":"breaking","affected_versions":"OpenColorIO 2.x.x (and corresponding types-opencolorio 2.x.x.x)"},{"fix":"Ensure both `pip install types-opencolorio` and `pip install opencolorio` are executed in your environment.","message":"The `types-opencolorio` package provides only type stubs. The actual runtime library, `PyOpenColorIO` (installed via `pip install opencolorio`), must be installed separately for your Python code to execute successfully. Without it, you will encounter `ModuleNotFoundError` at runtime.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Set the `OCIO` environment variable to the path of your `.ocio` configuration file. For example, `export OCIO=/path/to/my_config.ocio`.","message":"The `OCIO` environment variable is crucial for OpenColorIO applications as it typically points to the active configuration file. If this variable is not set or points to an invalid/incomplete configuration, `OCIO.GetCurrentConfig()` will fail, or applications may behave unexpectedly.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"search_vec":"'anim':37,79 'annual':68 'around':70 'bind':17 'check':11 'close':56 'code':54 'color':25,76 'color-manag':75 'complet':24 'comput':36 'effect':34 'emphas':32 'enabl':45 'enhanc':41 'follow':57 'ide':42 'librari':64 'like':47 'main':62 'manag':26,77 'motion':29 'mypi':48,85 'ocio':20,21,83 'opencolorio':7,19,63,84 'packag':40 'pictur':30 'post':81 'post-product':80 'product':31,82 'provid':8 'pyopencolorio':4,14,53 'python':1,16 'releas':69 'septemb':71 'solut':27 'static':9 'stub':2,12,39,74 'support':43 'tool':46 'type':6,10,50,73 'type-stub':72 'types-opencolorio':5 'typic':66 'valid':51 'version':59 'vfx':78 'visual':33","created_at":"2026-04-16T18:49:54.125809+00:00","updated_at":"2026-04-16T18:49:54.125809+00:00","problems":{"verify_error":"File \"<string>\", line 1\n    import PyOpenColorIO-stubs as OCIO\n                        ^\nSyntaxError: invalid syntax"},"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"2.4.2.0","cli_name":"","cli_version":null,"type":"library","homepage":"https://opencolorio.org","github":null,"docs":null,"changelog":null,"pypi":"https://pypi.org/project/types-opencolorio/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["type-stubs"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"import_fail","verified_at":"2026-07-03","last_verified":"2026-07-03","next_check":"2026-07-10","install_tag":null}}