def test_extract_lut(self): """Extract the 1d composante of a 3D LUT and plot the result """ csp_lut = os.path.join(self.tmpDir, "identity_3d_export.csp") ext_1d_lut.extract_1d_lut(self.lut3d, 10, csp_lut, True) plot_that_lut.plot_that_lut(csp_lut)
def test_convert_from_preset(self): """Read a preset file and write a LUT """ preset = presets.read_preset(self.sample_preset) outlutfile = os.path.join(self.tmp_dir, 'test_preset.cube') lut_to_lut(self.lut3d, preset=preset, outlutfile=outlutfile) proc = create_ocio_processor(outlutfile, interpolation=INTERP_LINEAR) proc.applyRGB([0, 0, 0]) proc.applyRGB([1, 1, 1]) if DISPLAY: import plot_that_lut plot_that_lut.plot_that_lut(outlutfile)
def test_default_3d_lut(self): """ Test a default 3d LUT export """ for helper, ext, ocio_compatible in self.helpers_3d_to_test: outlutfile = os.path.join(self.tmp_dir, "default_3D" + ext) args_3d = helper.get_default_preset() helper.write_3d_lut(self.processor_3d.applyRGB, outlutfile, args_3d) if ocio_compatible: # create a processor and try it proc = create_ocio_processor(outlutfile, interpolation=INTERP_LINEAR) proc.applyRGB([0, 0, 0]) proc.applyRGB([1, 1, 1]) if DISPLAY: import plot_that_lut plot_that_lut.plot_that_lut(outlutfile)
def test_default_1d_lut(self): """ Test a default 1d LUT export """ outlutfiles = [] for helper, ext in self.helpers_1d_to_test: outlutfile = os.path.join(self.tmp_dir, "default_1D" + ext) args_1d = helper.get_default_preset() helper.write_1d_lut(self.processor_1d.applyRGB, outlutfile, args_1d) # create a processor and try it proc = create_ocio_processor(outlutfile, interpolation=INTERP_LINEAR) proc.applyRGB([0, 0, 0]) proc.applyRGB([1, 1, 1]) outlutfiles.append(outlutfile) if DISPLAY: import plot_that_lut plot_that_lut.plot_that_lut(outlutfiles)
def upload(self, lutfile, lut_type, count, custom_count, inverse=False, prelutfile=None, postlutfile=None): # copy uploaded files on the server to use it with plot_that_lut backup_filename = self.__copyUploadedFile(lutfile) backup_pre_filename = None backup_post_filename = None label = 'Displaying : ' + backup_filename + ' (type : ' + lut_type if prelutfile.file: backup_pre_filename = self.__copyUploadedFile(prelutfile) if postlutfile.file: backup_post_filename = self.__copyUploadedFile(postlutfile) # init args label += ', samples : ' if count == 'custom': label += str(int(custom_count)) else: label += str(count) label += ', inverted : ' if inverse: label += "Yes" else: label += "No" label += ')' if prelutfile.file: label += ('<br/>Pre-LUT : ' + backup_pre_filename) if postlutfile.file: label += ('<br/>Post-LUT : ' + backup_post_filename) # call plot_that_lut to export the graph try: result_path = plot_that_lut.plot_that_lut(backup_filename, lut_type, tmp_count, inverse, backup_pre_filename, backup_post_filename) result = '<img src="/' + result_path + '" width=640 height=480 border=0 />' except Exception, e: error = str(e).replace('\n', '<br/>') result = '<h2>Something went wrong ! </h2><br/><font color="#FF0000">' + error + '</font><br>'
def upload( self, lutfile, lut_type, count, custom_count, inverse=False, prelutfile=None, postlutfile=None ): # copy uploaded files on the server to use it with plot_that_lut backup_filename = self.__copyUploadedFile( lutfile ) backup_pre_filename = None backup_post_filename = None label = 'Displaying : ' + backup_filename + ' (type : ' + lut_type if prelutfile.file: backup_pre_filename = self.__copyUploadedFile( prelutfile ) if postlutfile.file: backup_post_filename = self.__copyUploadedFile( postlutfile ) # init args label += ', samples : ' if count == 'custom': label += str( int( custom_count ) ) else: label += str( count ) label += ', inverted : ' if inverse: label += "Yes" else: label += "No" label += ')' if prelutfile.file: label += ('<br/>Pre-LUT : ' + backup_pre_filename ) if postlutfile.file: label += ('<br/>Post-LUT : ' + backup_post_filename ) # call plot_that_lut to export the graph try: result_path = plot_that_lut.plot_that_lut( backup_filename, lut_type, tmp_count, inverse, backup_pre_filename, backup_post_filename) result = '<img src="/' + result_path + '" width=640 height=480 border=0 />' except Exception, e: error = str( e ).replace( '\n', '<br/>' ) result = '<h2>Something went wrong ! </h2><br/><font color="#FF0000">' + error + '</font><br>'
def test_lut_3d(self): """Open a 3D LUT and display it """ plot_that_lut.plot_that_lut(self.lut3d, count=plot_that_lut.DEFAULT_CUBE_SIZE)
def test_lut_1d(self): """Open a 1D LUT and display it """ plot_that_lut.plot_that_lut(self.lut1d, count=plot_that_lut.DEFAULT_SAMPLE)
def plotThatLutUpload(self, lutfile, lut_type, count, custom_count, inverse=False, prelutfile=None, postlutfile=None): """PlotThatLUT plot page Args: lutfile (str): path to a color transformation file (lut, matrix...) lut_type (str): possible values are 'curve' or 'cube' count: possible values are 'custom' or 'auto' custom_count (int): custom count value kwargs: inverse (bool): inverse input lut prelutfile (str): path to a pre LUT postlutfile (str): path to a post LUT """ # copy uploaded files on the server to use it with plot_that_lut backup_filename = self.__copy_uploaded_file(lutfile) backup_pre_filename = None backup_post_filename = None if prelutfile.file: backup_pre_filename = self.__copy_uploaded_file(prelutfile) if postlutfile.file: backup_post_filename = self.__copy_uploaded_file(postlutfile) # init args if count == 'custom': tmp_count = int(custom_count) display_count = str(tmp_count) else: tmp_count = None display_count = count if inverse: inverse_text = "Yes" else: inverse_text = "No" label = ('Displaying : {0} (type : {1}, samples : {2}, inverted : {3})' ).format(backup_filename, lut_type, display_count, inverse_text) if prelutfile.file: label = ('{0}<br>Pre-LUT : {1}').format(label, backup_pre_filename) if postlutfile.file: label = ('{0}<br>Post-LUT : {1}').format(label, backup_post_filename) # call plot_that_lut to export the graph try: result = plot_that_lut.plot_that_lut(backup_filename, lut_type, tmp_count, inverse, backup_pre_filename, backup_post_filename) result = ( '<img src="/{0}" width="640" height="480"' 'border="0"/>' ).format(result) except Exception, e: error = str(e).replace('\n', '<br>') result = ( "<h2>Something went wrong ! </h2>" "<br>" '<font color="#FF0000">{0}</font><br>' ).format(error) print traceback.format_exc()
parser.add_argument('-v', "--version", action='version', version='{0} - version {1}'.format(description, __version__)) # full version versions = debug_helper.get_imported_modules_versions(sys.modules, globals()) versions = '{0} - version {1}\n\n{2}'.format(description, __version__, versions) parser.add_argument('-V', "--full-versions", action=debug_helper.make_full_version_action(versions)) ## return args return parser.parse_args() if __name__ == '__main__': """ Command line interface for plot_that_lut """ ARGS = __get_options() try: plot_that_lut.plot_that_lut(ARGS.lutfiles, ARGS.plot_type, ARGS.samples_count, ARGS.inverse, ARGS.prelutfile, ARGS.postlutfile, ARGS.markers) except Exception, exc: print "Watch out !\n%s" % exc
parser.add_argument("-t", "--plot-type", help=("Plot type. By default, a curve for a 1D/2D LUT " "and a cube for a 3D LUT."), type=str, choices=['auto', 'curve', 'cube'], default='auto') # samples count parser.add_argument( "-s", "--samples-count", help=("Samples count. Ex : {0} for a curve or {1} for a cube.").format( plot_that_lut.DEFAULT_SAMPLE, plot_that_lut.DEFAULT_CUBE_SIZE), default=None, type=int) ## return args return parser.parse_args() if __name__ == '__main__': """ Command line interface for plot_that_lut """ args = __get_options() try: plot_that_lut.plot_that_lut(args.lutfile, args.plot_type, args.samples_count, args.inverse, args.prelutfile, args.postlutfile) except Exception, e: print "Watch out !\n%s" % e
).format(plot_that_lut.supported_formats()), type=str, default=None) # type parser.add_argument("-t", "--plot-type", help=("Plot type. By default, a curve for a 1D/2D LUT " "and a cube for a 3D LUT."), type=str, choices=['auto', 'curve', 'cube'], default='auto') # samples count parser.add_argument("-s", "--samples-count", help=( "Samples count. Ex : {0} for a curve or {1} for a cube." ).format(plot_that_lut.DEFAULT_SAMPLE, plot_that_lut.DEFAULT_CUBE_SIZE), default=None, type=int) ## return args return parser.parse_args() if __name__ == '__main__': """ Command line interface for plot_that_lut """ args = __get_options() try: plot_that_lut.plot_that_lut(args.lutfile, args.plot_type, args.samples_count, args.inverse, args.prelutfile, args.postlutfile) except Exception, e: print "Watch out !\n%s" % e
plot_that_lut.DEFAULT_SAMPLE, plot_that_lut.DEFAULT_CUBE_SIZE), default=None, type=int) # version parser.add_argument('-v', "--version", action='version', version='{0} - version {1}'.format( description, __version__)) # full version versions = debug_helper.get_imported_modules_versions( sys.modules, globals()) versions = '{0} - version {1}\n\n{2}'.format(description, __version__, versions) parser.add_argument('-V', "--full-versions", action=debug_helper.make_full_version_action(versions)) # return args return parser.parse_args() if __name__ == '__main__': ARGS = __get_options() try: plot_that_lut.plot_that_lut(ARGS.lutfiles, ARGS.plot_type, ARGS.samples_count, ARGS.inverse, ARGS.prelutfile, ARGS.postlutfile, ARGS.markers) except Exception, exc: print "Watch out !\n%s" % exc