| 969 | "); |
| 970 | |
| 971 | static PyObject * |
| 972 | Image_write(PyImage* self, PyObject* args, PyObject* kwargs) |
| 973 | { |
| 974 | auto api = PyUtilApiFunction("s", PyRunTimeErr, __func__); |
| 975 | static char *keywords[] = {"file_name", NULL}; |
| 976 | char* fileName = NULL; |
| 977 | |
| 978 | if (!PyArg_ParseTupleAndKeywords(args, kwargs, api.format, keywords, &fileName)) { |
| 979 | return api.argsError(); |
| 980 | } |
| 981 | |
| 982 | if (!CheckImageData(api, self)) { |
| 983 | return nullptr; |
| 984 | } |
| 985 | |
| 986 | // Check that you can write to the file. |
| 987 | ofstream cfile; |
| 988 | cfile.open(fileName); |
| 989 | if (!cfile.is_open()) { |
| 990 | api.error("Unable to write the image to the file named '" + std::string(fileName) + "'."); |
| 991 | return nullptr; |
| 992 | } else { |
| 993 | cfile.close(); |
| 994 | } |
| 995 | |
| 996 | try { |
| 997 | WriteImage(self, std::string(fileName)); |
| 998 | } catch (std::exception &e) { |
| 999 | api.error(e.what()); |
| 1000 | return nullptr; |
| 1001 | } |
| 1002 | |
| 1003 | Py_RETURN_NONE; |
| 1004 | } |
| 1005 | |
| 1006 | //---------------------------- |
| 1007 | // Image_write_transformation |
nothing calls this directly
no test coverage detected