{"record":{"id":"6e23ffe337889ce6","repo":"Yalantis/uCrop","slug":"cimg-appname-math-parser-cimg-s-s-s-input-6e23ff","errorCode":null,"errorMessage":"[cimg_appname_math_parser] CImg<%s>::%s: %s: Input vector size (%lu values) and specified dimension of colormap entries (%u) do not match.","messagePattern":"\\[cimg_appname_math_parser\\] CImg<(.+?)>::(.+?): (.+?): Input vector size \\(%lu values\\) and specified dimension of colormap entries \\(%u\\) do not match\\.","errorType":"exception","errorClass":"CImgArgumentException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":22132,"sourceCode":"              _cimg_mp_check_const_scalar(arg3,3,3);\n              _cimg_mp_check_type(arg4,4,1,0);\n              _cimg_mp_check_const_scalar(arg5,5,2);\n              p1 = size(arg1);\n              p2 = size(arg2);\n              arg3 = (unsigned int)mem[arg3];\n              arg5 = (unsigned int)mem[arg5];\n              p3 = p2/arg3; // Number of color entries\n              if (p2!=p3*arg3) {\n                _cimg_mp_strerr;\n                throw CImgArgumentException(\"[\" cimg_appname \"_math_parser] \"\n                                            \"CImg<%s>::%s: %s: Colormap size (%lu values) and specified \"\n                                            \"dimension of colormap entries (%u) do not match.\",\n                                            pixel_type(),_cimg_mp_calling_function,s_op,\n                                            std::max(p2,1U),arg3);\n              }\n              if (p1%arg3) {\n                _cimg_mp_strerr;\n                throw CImgArgumentException(\"[\" cimg_appname \"_math_parser] \"\n                                            \"CImg<%s>::%s: %s: Input vector size (%lu values) and specified \"\n                                            \"dimension of colormap entries (%u) do not match.\",\n                                            pixel_type(),_cimg_mp_calling_function,s_op,\n                                            std::max(p1,1U),arg3);\n              }\n              pos = vector(arg5?p1:p1/arg3);\n              CImg<ulongT>::vector((ulongT)mp_index,pos,arg1,p1,arg2,p2,arg3,arg4,arg5).move_to(code);\n              return_comp = true;\n              _cimg_mp_return(pos);\n            }\n\n            if (!std::strncmp(ss,\"inrange(\",8)) { // Check value range\n              _cimg_mp_op(\"Function 'inrange()'\");\n              s1 = ss8; while (s1<se1 && (*s1!=',' || level[s1 - expr._data]!=clevel1)) ++s1;\n              arg1 = compile(ss8,s1,depth1,0,block_flags);\n              s2 = ++s1; while (s2<se1 && (*s2!=',' || level[s2 - expr._data]!=clevel1)) ++s2;\n              arg2 = compile(s1,s2,depth1,0,block_flags);\n              s1 = ++s2; while (s1<se1 && (*s1!=',' || level[s1 - expr._data]!=clevel1)) ++s1;","sourceCodeStart":22114,"sourceCodeEnd":22150,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L22114-L22150","documentation":"Sibling check to error 115 in the same operator: after validating the colormap, CImg verifies that the input vector size p1 is divisible by the colormap-entry dimension arg3. If the input data vector's length is not a multiple of the per-entry dimension, it throws this error reporting p1 and arg3.","triggerScenarios":"Passing an input vector of values (indices/coordinates/colors) whose size isn't a multiple of the entries dimension to the same palette/colormap function, e.g. a 7-value input with dimension 3 in a colormap-mapping expression.","commonSituations":"Feeding flattened images with an unexpected number of channels; forgetting to flatten exactly N*dim values; off-by-one when constructing the input vector; mixing channel counts between input and colormap.","solutions":["Ensure input vector length is a multiple of the entries dimension before calling","Align the input channel count with the colormap dimension (both 3 for RGB, both 4 for RGBA)","Compute and assert `input.size() % dim == 0` before building the expression","Reshape/pad the input via CImg API (get_resize / append) rather than inside the expression"],"exampleFix":"// before\nimg.fill(\"map([10,20,30,40], cmap, 3)\"); // 4 not divisible by 3\n// after\nimg.fill(\"map([10,20,30, 40,50,60], cmap, 3)\"); // 6 divisible by 3","handlingStrategy":"validation","validationCode":"void checkInputForColormap(double[] input, int dim) {\n  if (input.length % dim != 0)\n    throw new IllegalArgumentException(\"Input size \" + input.length + \" not a multiple of dim \" + dim);\n}","typeGuard":null,"tryCatchPattern":"try { img.fill(expr); } catch (CImgArgumentException e) { if (e.getMessage().contains(\"Input vector size\") && e.getMessage().contains(\"do not match\")) { /* pad/reshape input and retry */ } throw e; }","preventionTips":["Align input vector channel count with the colormap dimension","Validate input.length % dim == 0 before invoking the expression","Keep input and colormap layouts derived from the same constant"],"tags":["cimg","math-parser","colormap","size-mismatch"],"backgroundTag":"shape-mismatch","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"}