Yalantis/uCrop · error · CImgArgumentException
[" cimg_appname "_math_parser] CImg<%s>::%s: %s: Input vecto
Error message
[" cimg_appname "_math_parser] CImg<%s>::%s: %s: Input vector size (%lu values) and its specified geometry (%u,%u,%u,%u) (%lu values) do not match.
What it means
The math parser allows assigning an explicit geometry (width,height,depth,spectrum) to a vector. This error is thrown when the product of the four specified dimensions does not equal the actual number of values in the input vector (max(1,p1)), i.e. the declared shape and the data size disagree.
Source
Thrown at ucrop/src/main/jni/CImg.h:22589
s2 = ++s1; while (s2<se1 && (*s2!=',' || level[s2 - expr._data]!=clevel1)) ++s2;
arg4 = compile(s1,s2,depth1,0,block_flags);
s1 = ++s2; while (s1<se1 && (*s1!=',' || level[s1 - expr._data]!=clevel1)) ++s1;
arg5 = compile(s2,s1,depth1,0,block_flags);
arg6 = compile(++s1,se1,depth1,0,block_flags);
_cimg_mp_check_type(arg1,1,2,0);
_cimg_mp_check_const_scalar(arg2,2,3);
_cimg_mp_check_const_scalar(arg3,3,3);
_cimg_mp_check_const_scalar(arg4,4,3);
_cimg_mp_check_const_scalar(arg5,5,3);
p1 = size(arg1);
p2 = size(arg6);
arg2 = (unsigned int)mem[arg2];
arg3 = (unsigned int)mem[arg3];
arg4 = (unsigned int)mem[arg4];
arg5 = (unsigned int)mem[arg5];
if (arg2*arg3*arg4*arg5!=std::max(1U,p1)) {
_cimg_mp_strerr;
throw CImgArgumentException("[" cimg_appname "_math_parser] "
"CImg<%s>::%s: %s: Input vector size (%lu values) and its specified "
"geometry (%u,%u,%u,%u) (%lu values) do not match.",
pixel_type(),_cimg_mp_calling_function,s_op,
std::max(p1,1U),arg2,arg3,arg4,arg5,(ulongT)arg2*arg3*arg4*arg5);
}
pos = vector(arg2*arg3*arg4*arg5);
CImg<ulongT>::vector((ulongT)mp_mirror,pos,arg1,arg2,arg3,arg4,arg5,arg6,p2).move_to(code);
return_comp = true;
_cimg_mp_return(pos);
}
if (!std::strncmp(ss,"mproj(",6)) { // Project matrix onto dictionary
_cimg_mp_op("Function 'mproj()'");
s1 = ss6; while (s1<se1 && (*s1!=',' || level[s1 - expr._data]!=clevel1)) ++s1;
arg1 = compile(ss6,s1,depth1,0,block_flags); // S
s2 = ++s1; while (s2<se1 && (*s2!=',' || level[s2 - expr._data]!=clevel1)) ++s2;
arg2 = compile(s1,s2,depth1,0,block_flags); // ncolS
s1 = ++s2; while (s1<se1 && (*s1!=',' || level[s1 - expr._data]!=clevel1)) ++s1;View on GitHub (pinned to f788b534b4)
Solutions
- Compute w*h*d*s and compare against the actual vector size; fix the wrong dimension
- Use size(#ind) in a debug print to confirm the real element count
- Let the parser infer geometry by omitting explicit dims when possible
- Reshape the data first (e.g. with 'resize' or 'unroll') so the count matches
Example fix
// before (12 values declared as 3,4,1,1 = 12? no, declared 3,4,2,1=24) V = vector([1,2,3,4,5,6,7,8,9,10,11,12],3,4,2,1) // after V = vector([1,2,3,4,5,6,7,8,9,10,11,12],3,4,1,1)
Defensive patterns
Strategy: validation
Validate before calling
w*h*d*s == max(1,size(vec)) || error "geometry mismatch"
Try / catch
try { run(expr) } catch (CImgArgumentException &e) { log(e.what()); } Prevention
- Compute geometry product before hardcoding dims
- Account for the spectrum/channel dimension
- Prefer ops that infer geometry over explicit dims
When it happens
Trigger: Calling an expression like 'vector(v,w,h,d,s)' or a geometry-specifying op where w*h*d*s != vector length; typical with 'resize(#ind,...)' style ops or explicit vector declarations with wrong dimension values.
Common situations: Hardcoded geometry constants left over from an older image size, off-by-one in width/height, or forgetting the spectrum/channel factor (e.g. RGB vs gray).
Understand the failure class
Background: Tensor shape mismatch errors ("must have shape", "expected shape ... got ..."): when tensor dimensions disagree with what an op or layer was told to expect — this error's family across 6 libraries.
Related errors
- [cimg_appname_math_parser] CImg<%s>::%s: %s: Type of first a
- [cimg_appname_math_parser] CImg<%s>::%s: %s: Type of first a
- [" cimg_appname "_math_parser] CImg<%s>::%s: %s: Type of fir
- [" cimg_appname "_math_parser] CImg<%s>::%s: %s%s %s%s (of t
- [" cimg_appname "_math_parser] CImg<%s>: Function '%s()': Sp
AI-assisted analysis of Yalantis/uCrop@f788b534b4 (2026-09-08).
Data as JSON: /api/errors/b12936667020cf2d.
Report an issue: GitHub.