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 second argument 'nb_colsS=%u', in expression '%s'.

What it means

In a source/destination matrix-style operation, the first argument (source) must have size nb_colsS * nb_rowsS. When wS*hS != p1, the source column count 'nb_colsS' does not divide the source vector size, so the parser rejects the expression as a dimension mismatch.

Source

Thrown at ucrop/src/main/jni/CImg.h:22638

              }
              _cimg_mp_check_type(arg1,1,2,0);
              _cimg_mp_check_const_scalar(arg2,2,3);
              _cimg_mp_check_type(arg3,3,2,0);
              _cimg_mp_check_const_scalar(arg4,4,3);
              _cimg_mp_check_type(arg5,5,1,0);
              _cimg_mp_check_type(arg6,6,1,0);
              _cimg_mp_check_type(p3,7,1,0);
              p1 = size(arg1);
              p2 = size(arg3);
              const unsigned int
                wS = (unsigned int)mem[arg2],
                wD = (unsigned int)mem[arg4],
                hS = p1/wS,
                hD = p2/wD;

              if (wS*hS!=p1) {
                _cimg_mp_strerr;
                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] "

View on GitHub (pinned to f788b534b4)

Solutions

  1. Verify size(source) % nb_colsS == 0 and adjust the column count
  2. Print the source vector size before the op to confirm its length
  3. Reshape or unroll the source to match the expected rows x cols layout
  4. Check that the correct argument slot is being used (first arg is the source)

Example fix

// before: source has 12 values, nb_colsS=5
solve(S,D,5)
// after
solve(S,D,4) // 12 = 3 rows * 4 cols
Defensive patterns

Strategy: validation

Validate before calling

size(source) % nb_colsS == 0 || error "source size not divisible by nb_colsS"

Try / catch

try { run(expr) } catch (CImgArgumentException &e) { log(e.what()); }

Prevention

When it happens

Trigger: Calling a two-matrix math-parser op (e.g. a solve/transpose-style op taking S and D with explicit column counts) where nb_colsS does not divide size(arg1).

Common situations: Wrong column count constant in G'MIC formulas, source vector produced by a previous op with unexpected length, or mixing square and rectangular matrices.

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


AI-assisted analysis of Yalantis/uCrop@f788b534b4 (2026-09-08). Data as JSON: /api/errors/5a69e775acff9f0a. Report an issue: GitHub.