2020
2121
2222using namespace OIIO ;
23- using OIIO::Strutil::print;
2423
2524static std::string uninitialized = " uninitialized \001 HHRU dfvAS: efjl" ;
2625static std::string dataformatname = " " ;
@@ -103,7 +102,7 @@ getargs(int argc, char* argv[])
103102 nullptr );
104103 // clang-format on
105104 if (ap.parse (argc, (const char **)argv) < 0 ) {
106- print (stderr, " {}\n " , ap.geterror ());
105+ OIIO:: print (stderr, " {}\n " , ap.geterror ());
107106 ap.usage ();
108107 ap.abort ();
109108 return_code = EXIT_FAILURE;
@@ -117,7 +116,7 @@ getargs(int argc, char* argv[])
117116 }
118117
119118 if (filenames.size () != 2 && !inplace) {
120- print (
119+ OIIO:: print (
121120 stderr,
122121 " iconvert: Must have both an input and output filename specified.\n " );
123122 ap.usage ();
@@ -126,14 +125,14 @@ getargs(int argc, char* argv[])
126125 return ;
127126 }
128127 if (filenames.size () == 0 && inplace) {
129- print (stderr, " iconvert: Must have at least one filename\n " );
128+ OIIO:: print (stderr, " iconvert: Must have at least one filename\n " );
130129 ap.usage ();
131130 ap.abort ();
132131 return_code = EXIT_FAILURE;
133132 return ;
134133 }
135134 if (((int )rotcw + (int )rotccw + (int )rot180 + (orientation > 0 )) > 1 ) {
136- print (
135+ OIIO:: print (
137136 stderr,
138137 " iconvert: more than one of --rotcw, --rotccw, --rot180, --orientation\n " );
139138 ap.usage ();
@@ -151,7 +150,7 @@ DateTime_to_time_t(string_view datetime, time_t& timet)
151150 int year, month, day, hour, min, sec;
152151 if (!Strutil::scan_datetime (datetime, year, month, day, hour, min, sec))
153152 return false ;
154- // print("{}:{}:{} {}:{}:{}\n", year, month, day, hour, min, sec);
153+ // OIIO:: print("{}:{}:{} {}:{}:{}\n", year, month, day, hour, min, sec);
155154 struct tm tmtime;
156155 time_t now;
157156 Sysutil::get_local_time (&now, &tmtime); // fill in defaults
@@ -314,13 +313,14 @@ static bool
314313convert_file (const std::string& in_filename, const std::string& out_filename)
315314{
316315 if (noclobber && Filesystem::exists (out_filename)) {
317- print (stderr, " iconvert ERROR: Output file already exists \" {}\"\n " ,
318- out_filename);
316+ OIIO::print (stderr,
317+ " iconvert ERROR: Output file already exists \" {}\"\n " ,
318+ out_filename);
319319 return false ;
320320 }
321321
322322 if (verbose) {
323- print (" Converting {} to {}\n " , in_filename, out_filename);
323+ OIIO:: print (" Converting {} to {}\n " , in_filename, out_filename);
324324 fflush (stdout);
325325 }
326326
@@ -333,10 +333,11 @@ convert_file(const std::string& in_filename, const std::string& out_filename)
333333 auto in = ImageInput::open (in_filename);
334334 if (!in) {
335335 std::string err = geterror ();
336- print (stderr, " iconvert ERROR: {}\n " ,
337- (err.length () ? err
338- : Strutil::fmt::format (" Could not open \" {}\" " ,
339- in_filename)));
336+ OIIO::print (stderr, " iconvert ERROR: {}\n " ,
337+ (err.length ()
338+ ? err
339+ : Strutil::fmt::format (" Could not open \" {}\" " ,
340+ in_filename)));
340341 return false ;
341342 }
342343 ImageSpec inspec = in->spec ();
@@ -345,7 +346,7 @@ convert_file(const std::string& in_filename, const std::string& out_filename)
345346 // Find an ImageIO plugin that can open the output file, and open it
346347 auto out = ImageOutput::create (tempname);
347348 if (!out) {
348- print (
349+ OIIO:: print (
349350 stderr,
350351 " iconvert ERROR: Could not find an ImageIO plugin to write \" {}\" : {}\n " ,
351352 out_filename, geterror ());
@@ -375,10 +376,11 @@ convert_file(const std::string& in_filename, const std::string& out_filename)
375376 bool mip_to_subimage_warning = false ;
376377 for (int subimage = 0 ; ok && in->seek_subimage (subimage, 0 ); ++subimage) {
377378 if (subimage > 0 && !out->supports (" multiimage" )) {
378- print (stderr,
379- " iconvert WARNING: {} does not support multiple subimages.\n "
380- " \t Only the first subimage has been copied.\n " ,
381- out->format_name ());
379+ OIIO::print (
380+ stderr,
381+ " iconvert WARNING: {} does not support multiple subimages.\n "
382+ " \t Only the first subimage has been copied.\n " ,
383+ out->format_name ());
382384 break ; // we're done
383385 }
384386
@@ -398,17 +400,18 @@ convert_file(const std::string& in_filename, const std::string& out_filename)
398400 mode = ImageOutput::AppendSubimage; // use if we must
399401 if (!mip_to_subimage_warning
400402 && strcmp (out->format_name (), " tiff" )) {
401- print (stderr,
402- " iconvert WARNING: {} does not support MIPmaps.\n "
403- " \t Storing the MIPmap levels in subimages.\n " ,
404- out->format_name ());
403+ OIIO::print (
404+ stderr,
405+ " iconvert WARNING: {} does not support MIPmaps.\n "
406+ " \t Storing the MIPmap levels in subimages.\n " ,
407+ out->format_name ());
405408 }
406409 mip_to_subimage_warning = true ;
407410 } else {
408- print (stderr,
409- " iconvert WARNING: {} does not support MIPmaps.\n "
410- " \t Only the first level has been copied.\n " ,
411- out->format_name ());
411+ OIIO:: print (stderr,
412+ " iconvert WARNING: {} does not support MIPmaps.\n "
413+ " \t Only the first level has been copied.\n " ,
414+ out->format_name ());
412415 break ; // on to the next subimage
413416 }
414417 ok = out->open (tempname.c_str (), outspec, mode);
@@ -427,11 +430,11 @@ convert_file(const std::string& in_filename, const std::string& out_filename)
427430 }
428431 if (!ok) {
429432 std::string err = out->geterror ();
430- print (stderr, " iconvert ERROR: {}\n " ,
431- (err.length ()
432- ? err
433- : Strutil::fmt::format (" Could not open \" {}\" " ,
434- out_filename)));
433+ OIIO:: print (stderr, " iconvert ERROR: {}\n " ,
434+ (err.length ()
435+ ? err
436+ : Strutil::fmt::format (" Could not open \" {}\" " ,
437+ out_filename)));
435438 ok = false ;
436439 break ;
437440 }
@@ -450,23 +453,25 @@ convert_file(const std::string& in_filename, const std::string& out_filename)
450453 if (!nocopy) {
451454 ok = out->copy_image (in.get ());
452455 if (!ok)
453- print (stderr,
454- " iconvert ERROR copying \" {}\" to \" {}\" :\n\t {}\n " ,
455- in_filename, out_filename, out->geterror ());
456+ OIIO::print (
457+ stderr,
458+ " iconvert ERROR copying \" {}\" to \" {}\" :\n\t {}\n " ,
459+ in_filename, out_filename, out->geterror ());
456460 } else {
457461 // Need to do it by hand for some reason. Future expansion in which
458462 // only a subset of channels are copied, or some such.
459463 std::vector<char > pixels ((size_t )outspec.image_bytes (true ));
460464 ok = in->read_image (subimage, miplevel, 0 , outspec.nchannels ,
461465 outspec.format , &pixels[0 ]);
462466 if (!ok) {
463- print (stderr, " iconvert ERROR reading \" {}\" : {}\n " ,
464- in_filename, in->geterror ());
467+ OIIO:: print (stderr, " iconvert ERROR reading \" {}\" : {}\n " ,
468+ in_filename, in->geterror ());
465469 } else {
466470 ok = out->write_image (outspec.format , &pixels[0 ]);
467471 if (!ok)
468- print (stderr, " iconvert ERROR writing \" {}\" : {}\n " ,
469- out_filename, out->geterror ());
472+ OIIO::print (stderr,
473+ " iconvert ERROR writing \" {}\" : {}\n " ,
474+ out_filename, out->geterror ());
470475 }
471476 }
472477
0 commit comments