    }

    //! Generate a numbered version of a filename.
    inline char* number_filename(const char *const filename, const int number,
                                 const unsigned int digits, char *const str) {
      if (!filename) { if (str) *str = 0; return 0; }
      const unsigned int siz = (unsigned int)std::strlen(filename);
      CImg<char> format(16), body(siz + 32);
      const char *const ext = cimg::split_filename(filename,body);
      if (*ext) cimg_snprintf(format,format._width,"%%s_%%.%ud.%%s",digits);
      else cimg_snprintf(format,format._width,"%%s_%%.%ud",digits);
    }

     
    inline char* number_filename(const char *const filename, const int number,
                                 const unsigned int digits, char *const str) {
      if (!filename) { if (str) *str = 0; return 0; }
      const unsigned int siz = (unsigned int)std::strlen(filename);
      CImg<char> format(16), body(siz + 32);
      const char *const ext = cimg::split_filename(filename,body);
      if (*ext) cimg_snprintf(format,format._width,"%%s_%%.%ud.%%s",digits);
      else cimg_snprintf(format,format._width,"%%s_%%.%ud",digits);