Yalantis/uCrop · error · CImgArgumentException

[cimg_appname_math_parser] CImg<

Error message

[cimg_appname_math_parser] CImg<%s>::%s: %s: Too much arguments specified, in expression '%s'.

What it means

A function opcode dispatcher in the math parser received more arguments than any supported signature provides. The switch over argument count falls to the default case and reports 'Too much arguments specified'.

Solutions

  1. Check the CImg reference for the function's supported signatures and drop extra arguments
  2. Remove leftover trailing arguments (e.g. duplicate boundary values)
  3. Pin/verify the CImg version, as accepted arities can change between releases

Example fix

// before
noise(I,10,0,0,128,1);
// after
noise(I,10,0,0,128);
Defensive patterns

Strategy: validation

Validate before calling

// Validate arity of known built-ins before evaluation
const maxArity = { noise: 5, blur: 4 }; // extend per function per CImg version
function checkArity(expr) {
  for (const m of expr.matchAll(/([A-Za-z_]\w*)\s*\(([^()]*)\)/g)) {
    const fn = m[1], max = maxArity[fn];
    if (max !== undefined) {
      const n = m[2].split(',').filter(s => s.trim() !== '').length;
      if (n > max) throw new Error(`${fn} takes at most ${max} args, got ${n}`);
    }
  }
}

Try / catch

try {
  img.evaluate(expr);
} catch (e) {
  if (/Too much arguments specified/.test(String(e))) {
    // consult function docs and drop extra args
  } else throw e;
}

Prevention

When it happens

Trigger: Calling a math-parser built-in function with more arguments than its maximum supported overload (e.g. extra trailing arguments after the boundary argument).

Common situations: Misremembering a function signature, copy-pasted calls with leftover arguments, API changes between CImg versions altering maximum arity.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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

Appendix: source

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

                    move_to(opcode);
                  arg1 = 3 + arg2; break;
                case 6 :
                  CImg<ulongT>::vector(*opcode,opcode[1],opcode[2],0,opcode[3],opcode[4],opcode[5],~0U,
                                       _cimg_mp_boundary).move_to(opcode);
                  arg1 = 4 + arg2; break;
                case 7 :
                  CImg<ulongT>::vector(*opcode,opcode[1],opcode[2],0,opcode[3],opcode[4],opcode[5],~0U,
                                       opcode[6]).move_to(opcode);
                  arg1 = 4 + arg2; break;
                case 8 :
                  CImg<ulongT>::vector(*opcode,opcode[1],opcode[2],opcode[3],opcode[4],opcode[5],opcode[6],
                                       opcode[7],_cimg_mp_boundary).move_to(opcode);
                  arg1 = 5 + arg2; break;
                case 9 :
                  arg1 = 5 + arg2; break;
                default : // Error -> too much arguments
                  _cimg_mp_strerr;
                  throw CImgArgumentException("[" cimg_appname "_math_parser] "
                                              "CImg<%s>::%s: %s: Too much arguments specified, "
                                              "in expression '%s'.",
                                              pixel_type(),_cimg_mp_calling_function,s_op,s0);
                }

                if (opcode[4]!=(ulongT)~0U) {
                  _cimg_mp_check_const_scalar((unsigned int)opcode[4],arg1,3);
                  opcode[4] = (ulongT)mem[opcode[4]];
                }
                if (opcode[5]!=(ulongT)~0U) {
                  _cimg_mp_check_const_scalar((unsigned int)opcode[5],arg1 + 1,3);
                  opcode[5] = (ulongT)mem[opcode[5]];
                }
                if (opcode[6]!=(ulongT)~0U) {
                  _cimg_mp_check_const_scalar((unsigned int)opcode[6],arg1 + 2,3);
                  opcode[6] = (ulongT)mem[opcode[6]];
                }
                if (opcode[7]!=(ulongT)~0U) {

View on GitHub (pinned to f788b534b4)