diff --git a/include/GafferImage/ImageWriter.h b/include/GafferImage/ImageWriter.h index 948f072090a..b429d8815f5 100644 --- a/include/GafferImage/ImageWriter.h +++ b/include/GafferImage/ImageWriter.h @@ -37,6 +37,8 @@ #ifndef GAFFERIMAGE_IMAGEWRITER_H #define GAFFERIMAGE_IMAGEWRITER_H +#include "Gaffer/Expression.h" + #include "GafferDispatch/TaskNode.h" #include "GafferImage/TypeIds.h" @@ -102,6 +104,9 @@ class ImageWriter : public GafferDispatch::TaskNode ColorSpace *colorSpace(); const ColorSpace *colorSpace() const; + Gaffer::Expression *expr(); + const Gaffer::Expression *expr() const; + void createFileFormatOptionsPlugs(); static size_t g_firstPlugIndex; diff --git a/src/GafferImage/ImageWriter.cpp b/src/GafferImage/ImageWriter.cpp index 9b57dd36c0b..632bd938c2a 100644 --- a/src/GafferImage/ImageWriter.cpp +++ b/src/GafferImage/ImageWriter.cpp @@ -53,6 +53,7 @@ OIIO_NAMESPACE_USING #include "Gaffer/Context.h" #include "Gaffer/ScriptNode.h" #include "Gaffer/StringPlug.h" +#include "Gaffer/Expression.h" #include "GafferImage/FormatPlug.h" #include "GafferImage/ImageAlgo.h" @@ -863,6 +864,10 @@ ImageWriter::ImageWriter( const std::string &name ) outPlug()->setInput( inPlug() ); createFileFormatOptionsPlugs(); + + ExpressionPtr expression = new Expression( "__expression" ); + addChild( expression ); + //expression->setExpression( string( "parent[\"__colorSpace\"][\"outputSpace\"] = context.get(\"gaffer:colorspace\", \"linear\") " ), string( "python" ) ); } ImageWriter::~ImageWriter() @@ -990,6 +995,16 @@ const GafferImage::ImagePlug *ImageWriter::outPlug() const return getChild( g_firstPlugIndex+5 ); } +Expression *ImageWriter::expr() +{ + return getChild( g_firstPlugIndex+6 ); +} + +const Expression *ImageWriter::expr() const +{ + return getChild( g_firstPlugIndex+6 ); +} + Gaffer::ValuePlug *ImageWriter::fileFormatSettingsPlug( const std::string &fileFormat ) { return getChild( fileFormat ); @@ -1062,6 +1077,9 @@ void ImageWriter::execute() const Context * c = const_cast( Context::current() ); c->set( "gaffer:colorspace", defaultColorSpace()( currentFileFormat() ) ); + Expression * expression = const_cast( expr() ); + expression->setExpression( string( "parent[\"__colorSpace\"][\"outputSpace\"] = context.get(\"gaffer:colorspace\", \"\") " ), string( "python" ) ); + if( !inPlug()->getInput() ) { throw IECore::Exception( "No input image." );