Skip to content

Commit

Permalink
merge branch 'ctlrender-help' into dev
Browse files Browse the repository at this point in the history
This incorporates several clarifications to the usage and error messages that come with ctlrender.

Provides a temporary fix for ampas#39 by clarifying the reason why an EXR, which only supports 16 and 32 bps, will not be written when the input format implicitly defines an output bit depth other than 16 or 32 (e.g. input file is 10-bit DPX).

Closes ampas#38
  • Loading branch information
scottdyer committed Oct 20, 2015
2 parents 57b48a2 + 54b9e56 commit e71a12a
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 29 deletions.
7 changes: 5 additions & 2 deletions ctlrender/exr_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,11 @@ void exr_write(const char *name, float scale, const ctl::dpx::fb<float> &pixels,
exr_write16(name, scale, pixels, compression);
}
else {
THROW(Iex::ArgExc, "EXR files only support 16 or 32 bps at the moment.");
}
THROW(Iex::ArgExc, "EXR files only support 16 or 32 bits per sample; the implicitly requested \n"
"bits per sample is unsupported. Use -format exr16 or -format exr32 to \n
"explicitly request 16-bit or 32-bit floating-point EXR output."
);
}
}
#else
Expand Down
21 changes: 9 additions & 12 deletions ctlrender/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -448,11 +448,8 @@ int main(int argc, const char **argv)

if (input_image_files.size() < 2)
{
fprintf(stderr,
"one or more source filenames and a destination "
"file or directory must be\nprovided. if more than one "
"source filenames is provided then the last argument\nmust "
"be a directory. see -help for more details.\n");
usage(NULL);

exit(1);
}

Expand Down Expand Up @@ -489,9 +486,9 @@ int main(int argc, const char **argv)
if (!force_overwrite_output_file)
{
fprintf(stderr,
"The destination file %s already exists.\n"
"Cravenly refusing to overwrite unless you supply "
"the -force option.\n", outputFile);
"The destination file %s already exists. Refusing to overwrite the existing file.\n"
"To overwrite the existing file use the -force option.\n"
, outputFile);
exit(1);
}
else
Expand Down Expand Up @@ -568,8 +565,8 @@ int main(int argc, const char **argv)
"You have specified a destination file "
"type with the -format option, but the\noutput "
"file extension does not match the format "
"specified by the -format option.\nCravenly "
"refusing to do this unless you specify the "
"specified by the -format option.\nThis behavior "
"can be overridden by specifing the "
"-force option (which\nwill make the -format "
"option take priority).\n");
exit(1);
Expand Down Expand Up @@ -651,7 +648,7 @@ int main(int argc, const char **argv)
}
if (access(outputFile, F_OK) >= 0)
{
fprintf(stderr, "Cravenly refusing to overwrite the file '%s'.\n", outputFile);
fprintf(stderr, "Output file '%s' already exists. Refusing to overwrite.\n", outputFile);
exit(1);
}
actual_format.squish = noalpha;
Expand All @@ -663,7 +660,7 @@ int main(int argc, const char **argv)

} catch (std::exception &e)
{
fprintf(stderr, "exception thrown (oops...): %s\n", e.what());
fprintf(stderr, "\nexception thrown (oops...): %s\n", e.what());
return 1;
}
}
2 changes: 1 addition & 1 deletion ctlrender/transform.cc
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ void set_ctl_function_argument_from_ctl_results(Ctl::FunctionArgPtr *arg, const
}
else
{
THROW(Iex::ArgExc, "CTL parameter '" << dst->name() << "' not specified on the command line and does not have a default value.");
THROW(Iex::ArgExc, "A value for the CTL input variable '" << dst->name() << "' does not exist, was not specified on the command line,\nand does not have a default value. A value can be provided at runtime using command line parameters. See '-help param'\n");
throw(std::exception());
}
return;
Expand Down
47 changes: 33 additions & 14 deletions ctlrender/usage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@

void usage(const char *section) {
if(section==NULL) {
fprintf(stdout, ""
fprintf(stdout, "\n"
"ctlrender - transforms an image using one or more CTL scripts, potentially\n"
" converting the file format in the process\n"
"\nusage:\n"
Expand All @@ -83,6 +83,10 @@ void usage(const char *section) {
" option must be used.\n"
" See below for details on the '-format' option.\n"
"\n"
" If the destination file already exists, ctlrender \n"
" will refuse to overwrite the file unless the\n"
" -force parameter is supplied.\n"
"\n"
" -input_scale <value> Specifies a scaling value for the input.\n"
" Details on this are provided with '-help scale'.\n"
"\n"
Expand All @@ -108,11 +112,26 @@ void usage(const char *section) {
" -param2 ... Details on this and similar options are provided\n"
" -param3 ... with '-help param'\n"
"\n"
" -noalpha Specifies that <source_file> does not contain an \n"
" alpha channel.\n"
"\n"
" -force Allows overwriting of the destination file, if\n"
" the destination file already exists.\n"
"\n"
" -verbose Increases the level of output verbosity.\n"
" -quiet Decreases the level of output verbosity.\n"
"");
"\n"
" -force Overrides the default program behavior in some\n"
" instances such as overwriting existing files and\n"
" requiring format specified and file extensions\n"
" match.\n"
"\n"
" -help Prints this message. Additional help details are\n"
" available for some options by specifying an option\n"
" after '-help' (e.g. '-help format').\n"
"\n");
} else if(!strncmp(section, "format", 1)) {
fprintf(stdout, ""
fprintf(stdout, "\n"
"format conversion:\n"
"\n"
" ctlrender provides file format conversion either implicitly by the\n"
Expand Down Expand Up @@ -156,10 +175,10 @@ void usage(const char *section) {
"\n"
" Note that no automatic depth scaling is performed, please see\n"
" '-help scale' for more details on how scaling is performed.\n"
"");
"\n");
} else if(!strncmp(section, "compression", 2)) {
#if defined(HAVE_OPENEXR)
fprintf(stdout, ""
fprintf(stdout, "\n"
"exr compression:\n"
"\n"
" ctlrender provides the option of a compression scheme when saving an \n"
Expand All @@ -185,9 +204,9 @@ void usage(const char *section) {
"\n"
" B44A (lossy) Like B44 but smaller for images containing large\n"
" uniform areas.\n"
"");
"\n");
#else
fprintf(stdout, ""
fprintf(stdout, "\n"
"exr compression:\n"
"\n"
" ctlrender provides the option of a compression scheme when saving an \n"
Expand All @@ -198,21 +217,21 @@ void usage(const char *section) {
"\n"
" OpenEXR support must be enabled for the '-compression' option to be\n"
" meaningful. Please see build documentation for details.\n"
"");
"\n");
#endif
} else if(!strncmp(section, "ctl", 1)) {
fprintf(stdout, ""
fprintf(stdout, "\n"
"ctl file interpretation:\n"
" ctlrender treats all ctl files as if they take their input as 'R', 'G',\n"
" 'B', and 'A' (optional) channels, and produce output as 'R', 'G', and\n"
" 'B', and 'A' (if required) channels. In the event of a single channel\n"
" input file only the 'G' channel will be used.\n"
"");
"\n");
//" The *LAST* function in the file is the function that will be called to\n"
//" provide the transform. This is to maintain compatability with scripts\n"
//" developed for Autodesk's TOXIC product.\n"
} else if(!strncmp(section, "scale", 1)) {
fprintf(stderr, ""
fprintf(stderr, "\n"
"input and output value scaling:\n"
"\n"
" To deal with differences in input and output file bit depth, the ability\n"
Expand Down Expand Up @@ -258,9 +277,9 @@ void usage(const char *section) {
"\n"
" In all cases the CTL output values (after output_scaling) are clipped\n"
" to the maximum values supported by the output file format.\n"
"");
"\n");
} else if(!strncmp(section, "param", 1)) {
fprintf(stdout, ""
fprintf(stdout, "\n"
"ctl parameters:\n"
"\n"
" In CTL scripts it is possible to define parameters that are not set\n"
Expand All @@ -275,7 +294,7 @@ void usage(const char *section) {
" -global_param1 <name> <float1>\n"
" -global_param2 <name> <float1> <float2>\n"
" -global_param3 <name> <float1> <float2> <float3>\n"
"");
"\n");
} else {
fprintf(stdout, ""
"The '%s' section of the help does not exist. Try running ctlrender with\n"
Expand Down

0 comments on commit e71a12a

Please sign in to comment.