.. _ColorOperations/BakingAColorTransform:

Bake a Color Transform
======================

Problem
-------

You have an image file with an Alexa LogC LUT.  You want to bake the Alexa LUT to prepare the files for display.

Solution
--------

Use the :class:`Draft.LUT` class::

    import Draft

    inFile = '/path/to/input.exr'
    outFile = '/path/to/output.exr'

    img = Draft.Image.ReadFromFile( inFile )

    lut = Draft.LUT.CreateAlexaV3LogC().Inverse()
    lut.Apply( img )

    img.WriteToFile( outFile )

Discussion
----------

To create the LUT, we call :meth:`Draft.LUT.CreateAlexaV3LogC()`.  The resulting LUT will convert an image from Linear to Alexa V3 Log C.  This is the opposite of what we want, so we use the :meth:`~Draft.LUT.Inverse()` method.  This method returns a new LUT that will convert an image from Alexa V3 Log C to Linear, which is what we need.

We apply the LUT to the image::

    lut.Apply( img )

before we :meth:`~Draft.Image.WriteToFile`.

Draft includes several LUTs in addition to Alexa V3 Log C:

.. add_function_parentheses = False

================  =====================================
LUT               Draft command
================  =====================================
Cineon            :meth:`Draft.LUT.CreateCineon()`
Alexa V3 Log C    :meth:`Draft.LUT.CreateAlexaV3LogC()`
sRGB              :meth:`Draft.LUT.CreateSRGB()`
Rec. 709          :meth:`Draft.LUT.CreateRec709()`
Gamma correction  :meth:`Draft.LUT.CreateGamma()`
================  =====================================

See Also
--------

For the applying a Color Transform please review :ref:`ColorOperations/ConvertingColorSpaces`.
