Yalantis/uCrop · error · CImgArgumentException
[" cimg_appname "_math_parser] CImg<%s>::%s: %s: Type of fir
Error message
[" cimg_appname "_math_parser] CImg<%s>::%s: %s: Type of first argument ('%s') do not match with third argument ('%s'), in expression '%s'. What it means
For operations between a source and destination matrix, both must share the same number of rows (hS == hD). When the row counts differ (i.e. size(source)/nb_colsS != size(destination)/nb_colsD), the parser throws this mismatch error naming the first and third arguments.
Source
Thrown at ucrop/src/main/jni/CImg.h:22656
throw CImgArgumentException("[" cimg_appname "_math_parser] "
"CImg<%s>::%s: %s: Type of first argument ('%s') "
"do not match with second argument 'nb_colsS=%u', "
"in expression '%s'.",
pixel_type(),_cimg_mp_calling_function,s_op,
s_type(arg1)._data,wS,s0);
}
if (wD*hD!=p2) {
_cimg_mp_strerr;
throw CImgArgumentException("[" cimg_appname "_math_parser] "
"CImg<%s>::%s: %s: Type of third argument ('%s') "
"do not match with fourth argument 'nb_colsD=%u', "
"in expression '%s'.",
pixel_type(),_cimg_mp_calling_function,s_op,
s_type(arg3)._data,wD,s0);
}
if (hS!=hD) {
_cimg_mp_strerr;
throw CImgArgumentException("[" cimg_appname "_math_parser] "
"CImg<%s>::%s: %s: Type of first argument ('%s') "
"do not match with third argument ('%s'), "
"in expression '%s'.",
pixel_type(),_cimg_mp_calling_function,s_op,
s_type(arg1)._data,s_type(arg3)._data,s0);
}
pos = vector(wS*wD);
CImg<ulongT>::vector((ulongT)mp_mproj,pos,arg1,wS,hS,arg3,wD,arg5,arg6,p3).move_to(code);
return_comp = true;
_cimg_mp_return(pos);
}
if (!std::strncmp(ss,"mse(",4)) { // Mean-squared error
_cimg_mp_op("Function 'mse()'");
s1 = ss4; while (s1<se1 && (*s1!=',' || level[s1 - expr._data]!=clevel1)) ++s1;
arg1 = compile(ss4,s1,depth1,0,block_flags);
arg2 = compile(++s1,se1,depth1,0,block_flags);
_cimg_mp_check_type(arg2,2,is_scalar(arg1)?1:2,size(arg1));View on GitHub (pinned to f788b534b4)
Solutions
- Make size(S)/colsS equal size(D)/colsD by resizing one operand
- Recheck both column-count arguments; wrong values change implied row counts
- Print both vector sizes and column counts to verify row counts match
- Restructure the expression so both operands derive from the same geometry
Example fix
// before: S is 3x4 (12), D is 4x3 (12) but rows 3 != 4 op(S,D,4,3) // after op(S,D,4,4) // D resized to 3x4 (12 values) -> rows match
Defensive patterns
Strategy: validation
Validate before calling
size(source)/colsS == size(dst)/colsD || error "row counts differ"
Try / catch
try { run(expr) } catch (CImgArgumentException &e) { log(e.what()); } Prevention
- Derive both operands from the same geometry
- Verify implied row counts of both matrices
- Pad/crop operands to matching row counts
When it happens
Trigger: Two-matrix math-parser op where source and destination have different row counts, e.g. op(S,D,colsS,colsD) with size(S)/colsS != size(D)/colsD.
Common situations: Multiplying an m x n by a p x q matrix with p != m, forgetting to pad/crop the destination, or column-count typos that change the implied row count.
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 sec
- [" cimg_appname "_math_parser] CImg<%s>::%s: %s: Type of fir
- [" cimg_appname "_math_parser] CImg<%s>::%s: %s: Type of thi
- operator*(): Invalid multiplication of instance by specified
- [cimg_appname_math_parser] CImg<%s>::%s: %s: Too much specif
AI-assisted analysis of Yalantis/uCrop@f788b534b4 (2026-09-08).
Data as JSON: /api/errors/f2e238d89b88a79a.
Report an issue: GitHub.