Skip to content

Commit

Permalink
Merge branch 'main' into feature/add_rgba_for_metal
Browse files Browse the repository at this point in the history
  • Loading branch information
wRosie authored Aug 19, 2024
2 parents 7b611ef + 4944d6e commit 646cf51
Show file tree
Hide file tree
Showing 62 changed files with 2,995 additions and 1,071 deletions.
39 changes: 39 additions & 0 deletions docs/api/python/src/pyopencolorio_gradingprimary.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,42 @@
:members:
:undoc-members:
:special-members: __init__, __str__

.. attribute:: brightness
:type: GradingRGBM

.. attribute:: clampBlack
:type: float

.. attribute:: clampWhite
:type: float

.. attribute:: contrast
:type: GradingRGBM

.. attribute:: exposure
:type: GradingRGBM

.. attribute:: gain
:type: GradingRGBM

.. attribute:: gamma
:type: GradingRGBM

.. attribute:: lift
:type: GradingRGBM

.. attribute:: offset
:type: GradingRGBM

.. attribute:: pivot
:type: float

.. attribute:: pivotBlack
:type: float

.. attribute:: pivotWhite
:type: float

.. attribute:: saturation
:type: float
5 changes: 4 additions & 1 deletion docs/guides/using_ocio/compatible_software.rst
Original file line number Diff line number Diff line change
Expand Up @@ -334,9 +334,12 @@ PhotoFlow supports OCIO via a dedicated tool that can load a given configuration
Website : `<https://github.com/aferrero2707/PhotoFlow>`__


Photoshop
Photoshop (beta)
*********
OCIO can be enabled via a technology preview checkbox in preferences. For more details see `OpenColorIO and 32-bit Editing now available in Photoshop Beta <https://community.adobe.com/t5/photoshop-beta-discussions/new-feature-opencolorio-and-32-bit-editing-now-available-in-photoshop-beta/td-p/14767506>`__.

Photoshop
*********
OpenColorIO display luts can be exported as ICC profiles for use in photoshop. The core idea is to create an .icc profile, with a valid description, and then to save it to the proper OS icc directory. (On OSX, ``~/Library/ColorSync/Profiles/``). Upon a Photoshop relaunch, Edit->Assign Profile, and then select your new OCIO lut.

Website : `<https://www.adobe.com/products/photoshop.html>`__
Expand Down
26 changes: 11 additions & 15 deletions src/OpenColorIO/OCIOYaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4034,7 +4034,7 @@ inline void load(const YAML::Node & node, ViewingRulesRcPtr & vr)
catch (Exception & ex)
{
std::ostringstream os;
os << "File rules: " << ex.what();
os << "Viewing rules: " << ex.what();
throwError(node, os.str().c_str());
}
}
Expand Down Expand Up @@ -4658,13 +4658,15 @@ inline void load(const YAML::Node& node, ConfigRcPtr & config, const char* filen
config->setWorkingDir(configrootdir.c_str());
}

auto defaultCS = config->getColorSpace(ROLE_DEFAULT);
if (!fileRulesFound)
{
if (config->getMajorVersion() >= 2)
{
if (!defaultCS)
if (!config->hasRole(ROLE_DEFAULT))
{
// Note that no validation of the default color space is done (e.g. to check that
// it exists in the config) in order to enable loading configs that are only
// partially complete. The caller may use config->validate() after, if desired.
throwError(node, "The config must contain either a Default file rule or "
"the 'default' role.");
}
Expand All @@ -4683,6 +4685,7 @@ inline void load(const YAML::Node& node, ConfigRcPtr & config, const char* filen
else
{
// If default role is also defined.
auto defaultCS = config->getColorSpace(ROLE_DEFAULT);
if (defaultCS)
{
const auto defaultRule = fileRules->getNumEntries() - 1;
Expand Down Expand Up @@ -4815,18 +4818,11 @@ inline void save(YAML::Emitter & out, const Config & config)
const char* role = config.getRoleName(i);
if(role && *role)
{
ConstColorSpaceRcPtr colorspace = config.getColorSpace(role);
if(colorspace)
{
out << YAML::Key << role;
out << YAML::Value << config.getColorSpace(role)->getName();
}
else
{
std::ostringstream os;
os << "Colorspace associated to the role '" << role << "', does not exist.";
throw Exception(os.str().c_str());
}
// Note that no validation of the name strings is done here (e.g. to check that
// they exist in the config) in order to enable serializing configs that are only
// partially complete. The caller may use config->validate() first, if desired.
out << YAML::Key << role;
out << YAML::Value << config.getRoleColorSpace(i);
}
}
out << YAML::EndMap;
Expand Down
139 changes: 109 additions & 30 deletions src/apps/ocioconvert/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,34 +49,40 @@ int main(int argc, const char **argv)
std::vector<std::string> intAttrs;
std::vector<std::string> stringAttrs;

bool usegpu = false;
bool usegpuLegacy = false;
bool outputgpuInfo = false;
bool verbose = false;
bool help = false;
bool useLut = false;
bool useDisplayView = false;
bool useInvertView = false;
bool usegpu = false;
bool usegpuLegacy = false;
bool outputgpuInfo = false;
bool verbose = false;
bool help = false;
bool useLut = false;
bool useDisplayView = false;
bool useInvertView = false;
bool useNamedTransform = false;
bool useInvNamedTransform = false;

ap.options("ocioconvert -- apply colorspace transform to an image \n\n"
"usage: ocioconvert [options] inputimage inputcolorspace outputimage outputcolorspace\n"
" or: ocioconvert [options] --lut lutfile inputimage outputimage\n"
" or: ocioconvert [options] --view inputimage inputcolorspace outputimage displayname viewname\n"
" or: ocioconvert [options] --invertview inputimage displayname viewname outputimage outputcolorspace\n\n",
" or: ocioconvert [options] --invertview inputimage displayname viewname outputimage outputcolorspace\n"
" or: ocioconvert [options] --namedtransform transformname inputimage outputimage\n"
" or: ocioconvert [options] --invnamedtransform transformname inputimage outputimage\n\n",
"%*", parse_end_args, "",
"<SEPARATOR>", "Options:",
"--lut", &useLut, "Convert using a LUT rather than a config file",
"--view", &useDisplayView, "Convert to a (display,view) pair rather than to "
"an output color space",
"--invertview", &useInvertView, "Convert from a (display,view) pair rather than "
"from a color space",
"--gpu", &usegpu, "Use GPU color processing instead of CPU (CPU is the default)",
"--gpulegacy", &usegpuLegacy, "Use the legacy (i.e. baked) GPU color processing "
"instead of the CPU one (--gpu is ignored)",
"--gpuinfo", &outputgpuInfo, "Output the OCIO shader program",
"--h", &help, "Display the help and exit",
"--help", &help, "Display the help and exit",
"-v" , &verbose, "Display general information",
"--lut", &useLut, "Convert using a LUT rather than a config file",
"--view", &useDisplayView, "Convert to a (display,view) pair rather than to "
"an output color space",
"--invertview", &useInvertView, "Convert from a (display,view) pair rather than "
"from a color space",
"--namedtransform", &useNamedTransform, "Convert using a named transform in the forward direction",
"--invnamedtransform", &useInvNamedTransform, "Convert using a named transform in the inverse direction",
"--gpu", &usegpu, "Use GPU color processing instead of CPU (CPU is the default)",
"--gpulegacy", &usegpuLegacy, "Use the legacy (i.e. baked) GPU color processing "
"instead of the CPU one (--gpu is ignored)",
"--gpuinfo", &outputgpuInfo, "Output the OCIO shader program",
"--h", &help, "Display the help and exit",
"--help", &help, "Display the help and exit",
"-v" , &verbose, "Display general information",
"<SEPARATOR>", "\nOpenImageIO or OpenEXR options:",
"--float-attribute %L", &floatAttrs, "\"name=float\" pair defining OIIO float attribute "
"for outputimage",
Expand Down Expand Up @@ -109,15 +115,16 @@ int main(int argc, const char **argv)
}
#endif // OCIO_GPU_ENABLED

const char * inputimage = nullptr;
const char * inputcolorspace = nullptr;
const char * outputimage = nullptr;
const char * outputcolorspace = nullptr;
const char * lutFile = nullptr;
const char * display = nullptr;
const char * view = nullptr;

if (!useLut && !useDisplayView && !useInvertView)
const char * inputimage = nullptr;
const char * inputcolorspace = nullptr;
const char * outputimage = nullptr;
const char * outputcolorspace = nullptr;
const char * lutFile = nullptr;
const char * display = nullptr;
const char * view = nullptr;
const char * namedtransform = nullptr;

if (!useLut && !useDisplayView && !useInvertView && !useNamedTransform && !useInvNamedTransform)
{
if (args.size() != 4)
{
Expand Down Expand Up @@ -186,6 +193,50 @@ int main(int argc, const char **argv)
outputimage = args[3].c_str();
outputcolorspace = args[4].c_str();
}
else if (useNamedTransform)
{
if (useLut || useDisplayView || useInvertView || useInvNamedTransform)
{
std::cerr << "ERROR: Option namedtransform can't be used with lut, view, invertview, \
or invnamedtransform at the same time." << std::endl;
ap.usage();
exit(1);
}

if (args.size() != 3)
{
std::cerr << "ERROR: Expecting 3 arguments for --namedtransform option, found "
<< args.size() << "." << std::endl;
ap.usage();
exit(1);
}

namedtransform = args[0].c_str();
inputimage = args[1].c_str();
outputimage = args[2].c_str();
}
else if (useInvNamedTransform)
{
if (useLut || useDisplayView || useInvertView || useNamedTransform)
{
std::cerr << "ERROR: Option invnamedtransform can't be used with lut, view, invertview, \
or namedtransform at the same time." << std::endl;
ap.usage();
exit(1);
}

if (args.size() != 3)
{
std::cerr << "ERROR: Expecting 3 arguments for --invnamedtransform option, found "
<< args.size() << "." << std::endl;
ap.usage();
exit(1);
}

namedtransform = args[0].c_str();
inputimage = args[1].c_str();
outputimage = args[2].c_str();
}

if (verbose)
{
Expand Down Expand Up @@ -343,6 +394,34 @@ int main(int argc, const char **argv)
t->setView(view);
processor = config->getProcessor(t, OCIO::TRANSFORM_DIR_INVERSE);
}
else if (useNamedTransform)
{
auto nt = config->getNamedTransform(namedtransform);

if (nt)
{
processor = config->getProcessor(nt, OCIO::TRANSFORM_DIR_FORWARD);
}
else
{
std::cout << "ERROR: Could not get NamedTransform " << namedtransform << std::endl;
exit(1);
}
}
else if (useInvNamedTransform)
{
auto nt = config->getNamedTransform(namedtransform);

if (nt)
{
processor = config->getProcessor(nt, OCIO::TRANSFORM_DIR_INVERSE);
}
else
{
std::cout << "ERROR: Could not get NamedTransform " << namedtransform << std::endl;
exit(1);
}
}
else
{
processor = config->getProcessor(inputcolorspace, outputcolorspace);
Expand Down
59 changes: 4 additions & 55 deletions src/apps/ocioview/main.py
Original file line number Diff line number Diff line change
@@ -1,68 +1,17 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright Contributors to the OpenColorIO Project.

import logging
import os
import sys
from pathlib import Path

import PyOpenColorIO as ocio
from PySide6 import QtCore, QtGui, QtWidgets

import ocioview.log_handlers # Import to initialize logging
from ocioview.main_window import OCIOView
from ocioview.style import QSS, DarkPalette


ROOT_DIR = Path(__file__).resolve().parent.parent
FONTS_DIR = ROOT_DIR / "fonts"


def excepthook(exc_type, exc_value, exc_tb):
"""Log uncaught errors"""
if issubclass(exc_type, KeyboardInterrupt):
sys.__excepthook__(exc_type, exc_value, exc_tb)
return
logging.error(f"{exc_value}", exc_info=exc_value)
from ocioview.setup import setup_app


if __name__ == "__main__":
sys.excepthook = excepthook

# OpenGL core profile needed on macOS to access programmatic pipeline
gl_format = QtGui.QSurfaceFormat()
gl_format.setProfile(QtGui.QSurfaceFormat.CoreProfile)
gl_format.setSwapInterval(1)
gl_format.setVersion(4, 0)
QtGui.QSurfaceFormat.setDefaultFormat(gl_format)

# Create app
app = QtWidgets.QApplication(sys.argv)

# Initialize style
app.setStyle("fusion")
app.setPalette(DarkPalette())
app.setStyleSheet(QSS)
app.setEffectEnabled(QtCore.Qt.UI_AnimateCombo, False)

font = app.font()
font.setPointSize(8)
app.setFont(font)

# Clean OCIO environment to isolate working config
for env_var in (
ocio.OCIO_CONFIG_ENVVAR,
ocio.OCIO_ACTIVE_VIEWS_ENVVAR,
ocio.OCIO_ACTIVE_DISPLAYS_ENVVAR,
ocio.OCIO_INACTIVE_COLORSPACES_ENVVAR,
ocio.OCIO_OPTIMIZATION_FLAGS_ENVVAR,
ocio.OCIO_USER_CATEGORIES_ENVVAR,
):
if env_var in os.environ:
del os.environ[env_var]
app = setup_app()

# Start ocioview
ocioview = OCIOView()
ocioview.show()
ocio_view = OCIOView()
ocio_view.show()

sys.exit(app.exec_())
Loading

0 comments on commit 646cf51

Please sign in to comment.