Do the file extension and encoding match?
| 104 | |
| 105 | // Do the file extension and encoding match? |
| 106 | static bool matchExt(const std::string & fn, |
| 107 | std::string en) { |
| 108 | size_t p = fn.rfind('.'); |
| 109 | std::string ext = p != fn.npos ? fn.substr(p) : fn; |
| 110 | std::transform(ext.begin(), ext.end(), ext.begin(), ::tolower); |
| 111 | std::transform(en.begin(), en.end(), en.begin(), ::tolower); |
| 112 | if ( ext == en ) |
| 113 | return true; |
| 114 | if ( en == "jpg" && ext == "jpeg" ) |
| 115 | return true; |
| 116 | return false; |
| 117 | } |
| 118 | |
| 119 | bool ReadImageToDatum(const string& filename, const int label, |
| 120 | const int height, const int width, const bool is_color, |
no test coverage detected