std::string save_to_string(T const& image, std::string const& type) { std::ostringstream ss(std::ios::out|std::ios::binary); save_to_stream(image, ss, type); return ss.str(); }
void save_to_file(T const& image, std::string const& filename, std::string const& type) { std::ofstream file (filename.c_str(), std::ios::out| std::ios::trunc|std::ios::binary); if (file) { save_to_stream(image, file, type); } else throw ImageWriterException("Could not write file to " + filename ); }