File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1160,8 +1160,26 @@ test_shade (int argc, const char *argv[])
11601160 // Write the output images to disk
11611161 for (size_t i = 0 ; i < outputimgs.size (); ++i) {
11621162 if (outputimgs[i]) {
1163- if (! print_outputs)
1164- outputimgs[i]->write (outputimgs[i]->name ());
1163+ if (! print_outputs) {
1164+ std::string filename = outputimgs[i]->name ();
1165+ // JPEG, GIF, and PNG images should be automatically saved
1166+ // as sRGB because they are almost certainly supposed to
1167+ // be displayed on web pages.
1168+ using namespace OIIO ;
1169+ if (Strutil::iends_with (filename, " .jpg" ) ||
1170+ Strutil::iends_with (filename, " .jpeg" ) ||
1171+ Strutil::iends_with (filename, " .gif" ) ||
1172+ Strutil::iends_with (filename, " .png" )) {
1173+ ImageBuf ccbuf;
1174+ ImageBufAlgo::colorconvert (ccbuf, *outputimgs[i],
1175+ " linear" , " sRGB" , false ,
1176+ " " , " " );
1177+ ccbuf.set_write_format (outputimgs[i]->spec ().format );
1178+ ccbuf.write (filename);
1179+ } else {
1180+ outputimgs[i]->write (filename);
1181+ }
1182+ }
11651183 delete outputimgs[i];
11661184 outputimgs[i] = NULL ;
11671185 }
You can’t perform that action at this time.
0 commit comments