Yalantis/uCrop · error · CImgArgumentException
[cimg_appname_math_parser] CImg<%s>::%s: %s: Input vector si
Error message
[cimg_appname_math_parser] CImg<%s>::%s: %s: Input vector size (%lu values) and specified dimension of colormap entries (%u) do not match.
What it means
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.
Source
Thrown at ucrop/src/main/jni/CImg.h:22132
_cimg_mp_check_const_scalar(arg3,3,3);
_cimg_mp_check_type(arg4,4,1,0);
_cimg_mp_check_const_scalar(arg5,5,2);
p1 = size(arg1);
p2 = size(arg2);
arg3 = (unsigned int)mem[arg3];
arg5 = (unsigned int)mem[arg5];
p3 = p2/arg3; // Number of color entries
if (p2!=p3*arg3) {
_cimg_mp_strerr;
throw CImgArgumentException("[" cimg_appname "_math_parser] "
"CImg<%s>::%s: %s: Colormap size (%lu values) and specified "
"dimension of colormap entries (%u) do not match.",
pixel_type(),_cimg_mp_calling_function,s_op,
std::max(p2,1U),arg3);
}
if (p1%arg3) {
_cimg_mp_strerr;
throw CImgArgumentException("[" cimg_appname "_math_parser] "
"CImg<%s>::%s: %s: Input vector size (%lu values) and specified "
"dimension of colormap entries (%u) do not match.",
pixel_type(),_cimg_mp_calling_function,s_op,
std::max(p1,1U),arg3);
}
pos = vector(arg5?p1:p1/arg3);
CImg<ulongT>::vector((ulongT)mp_index,pos,arg1,p1,arg2,p2,arg3,arg4,arg5).move_to(code);
return_comp = true;
_cimg_mp_return(pos);
}
if (!std::strncmp(ss,"inrange(",8)) { // Check value range
_cimg_mp_op("Function 'inrange()'");
s1 = ss8; while (s1<se1 && (*s1!=',' || level[s1 - expr._data]!=clevel1)) ++s1;
arg1 = compile(ss8,s1,depth1,0,block_flags);
s2 = ++s1; while (s2<se1 && (*s2!=',' || level[s2 - expr._data]!=clevel1)) ++s2;
arg2 = compile(s1,s2,depth1,0,block_flags);
s1 = ++s2; while (s1<se1 && (*s1!=',' || level[s1 - expr._data]!=clevel1)) ++s1;View on GitHub (pinned to f788b534b4)
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
Example fix
// before
img.fill("map([10,20,30,40], cmap, 3)"); // 4 not divisible by 3
// after
img.fill("map([10,20,30, 40,50,60], cmap, 3)"); // 6 divisible by 3 Defensive patterns
Strategy: validation
Validate before calling
void checkInputForColormap(double[] input, int dim) {
if (input.length % dim != 0)
throw new IllegalArgumentException("Input size " + input.length + " not a multiple of dim " + dim);
} Try / catch
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; } Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- [cimg_appname_math_parser] CImg<%s>::%s: %s: Colormap size (
- [cimg_appname_math_parser] CImg<%s>::%s: %s: Specified input
- [cimg_appname_math_parser] CImg<%s>::%s: %s: Specified kerne
- [" cimg_appname "_math_parser] CImg<%s>: Function '%s()': El
- "[" cimg_appname "_math_parser] CImg<%s>: Function '%s()': E
AI-assisted analysis of Yalantis/uCrop@f788b534b4 (2026-09-08).
Data as JSON: /api/errors/6e23ffe337889ce6.
Report an issue: GitHub.