{"record":{"id":"15003c8d306eca6a","repo":"Yalantis/uCrop","slug":"mirror-invalid-specified-axis-c","errorCode":null,"errorMessage":"mirror(): Invalid specified axis '%c'.","messagePattern":"mirror\\(\\): Invalid specified axis '%c'\\.","errorType":"validation","errorClass":"CImgArgumentException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":39030,"sourceCode":"          }\n          pf+=(ulongT)_width*_height*(_depth - depth2);\n          pb+=(ulongT)_width*_height*(_depth + depth2);\n        }\n      } break;\n      case 'c' : {\n        buf = new T[(ulongT)_width*_height*_depth];\n        pf = _data; pb = data(0,0,0,_spectrum - 1);\n        const unsigned int _spectrum2 = _spectrum/2;\n        for (unsigned int v = 0; v<_spectrum2; ++v) {\n          std::memcpy(buf,pf,_width*_height*_depth*sizeof(T));\n          std::memcpy(pf,pb,_width*_height*_depth*sizeof(T));\n          std::memcpy(pb,buf,_width*_height*_depth*sizeof(T));\n          pf+=(ulongT)_width*_height*_depth;\n          pb-=(ulongT)_width*_height*_depth;\n        }\n      } break;\n      default :\n        throw CImgArgumentException(_cimg_instance\n                                    \"mirror(): Invalid specified axis '%c'.\",\n                                    cimg_instance,\n                                    axis);\n      }\n      delete[] buf;\n      return *this;\n    }\n\n    //! Mirror image content along specified axis \\newinstance.\n    CImg<T> get_mirror(const char axis) const {\n      return (+*this).mirror(axis);\n    }\n\n    //! Mirror image content along specified axes.\n    /**\n       \\param axes Mirror axes, as a C-string.\n       \\note \\c axes may contains multiple characters, e.g. \\c \"xyz\"\n    **/","sourceCodeStart":39012,"sourceCodeEnd":39048,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L39012-L39048","documentation":"CImg's mirror() takes an axis selector that must be one of 'x', 'y', 'z' or 'c'; the internal switch handles only those cases. Any other character reaches the default branch, which throws CImgArgumentException reporting the offending character. The library requires an exact single-character axis identifier.","triggerScenarios":"Calling CImg<T>::mirror(axis) with a character other than 'x', 'y', 'z', or 'c' — e.g. 'X' or 'Y' (wrong case), 'horizontal'/'vertical' strings converted wrongly, '0'/'1', a null byte, or a truncated two-character code like 'xy'.","commonSituations":"Mapping user-facing 'flip horizontal/vertical' options to axis chars with wrong-case output ('X' instead of 'x'); porting code from another library that uses 0/1 axis indices; config files supplying axis names with trailing whitespace or newline characters.","solutions":["Pass exactly one of 'x', 'y', 'z', or 'c' (lowercase) to mirror().","If your input is uppercase or a word like 'horizontal', normalize it: map to lowercase and translate words to the corresponding axis character before calling.","Validate the axis character at the call boundary and reject/normalize invalid values with a clear app-level message.","If you need a flip along a different axis, ensure the image actually has that dimension (e.g. 'z' on a 2D image is also not handled — use 'x' or 'y')."],"exampleFix":"// before\nimg.mirror('X'); // invalid: wrong case\n// after\nimg.mirror('x'); // lowercase axis chars only","handlingStrategy":"validation","validationCode":"// C++\nbool isValidAxis(char axis) { return axis=='x' || axis=='y' || axis=='z' || axis=='c'; }\nchar axis = std::tolower(userAxis);\nif (!isValidAxis(axis)) throw std::invalid_argument(\"axis must be x, y, z, or c\");\nimg.mirror(axis);","typeGuard":"bool isValidAxis(char c) { return c=='x'||c=='y'||c=='z'||c=='c'; }","tryCatchPattern":"try {\n    img.mirror(axis);\n} catch (const cimg_library::CImgArgumentException& e) {\n    // log and default to a sensible axis\n    img.mirror('x');\n}","preventionTips":["Always lowercase axis input before passing to mirror()","Map word-based options ('horizontal'/'vertical') to 'x'/'y' in one central helper","Reject 0/1 numeric axis indices from other libraries; translate them explicitly","Trim strings from config files so no whitespace/newline leaks into the axis char"],"tags":["cimg","invalid-argument","image-mirror","axis"],"backgroundTag":"invalid-enum-value","analyzedSha":"f788b534b48c144edf786c8cddbf0e029e637804","analyzedAt":"2026-09-08T08:36:04.887Z","contentChangedAt":"2026-09-08T08:36:04.887Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}