Yalantis/uCrop · error · CImgArgumentException
[cimg_appname_math_parser] CImg<%s>::%s: %s: %s arguments pr
Error message
[cimg_appname_math_parser] CImg<%s>::%s: %s: %s arguments provided, in expression '%s'.
What it means
An argument-count guard for a math-parser opcode that requires between 12 and opcode._height arguments (the first arguments are mandatory: input image variable, width, etc.). If fewer than 12 were parsed, it reports 'Not enough arguments'; more than the opcode height means 'Too much'. The check runs after parsing the argument list into l_opcode/opcode, before type-checking the image and width arguments.
Source
Thrown at ucrop/src/main/jni/CImg.h:20913
1,1,1, // [21]=xdilation, [22]=ydilation, [23]=zdilation,
0,0,0, // [24]=xoffset, [25]=yoffset, [26]=zoffset
~0U,~0U,~0U}; // [27]=xsize, [28]=ysize, [29]=zsize
l_opcode.assign(); // Don't use 'opcode': it could be modified by further calls to 'compile()'!
CImg<ulongT>(default_params,1,sizeof(default_params)/sizeof(ulongT)).move_to(l_opcode);
arg1 = 2;
for (s = std::strchr(ss,'(') + 1; s<se && arg1<l_opcode[0]._height; ++s) {
ns = s; while (ns<se && (*ns!=',' || level[ns - expr._data]!=clevel1) &&
(*ns!=')' || level[ns - expr._data]!=clevel)) ++ns;
l_opcode(0,arg1++) = compile(s,ns,depth1,0,block_flags);
s = ns;
}
l_opcode[0].move_to(opcode);
if (arg1<12 || arg1>opcode._height) {
_cimg_mp_strerr;
throw CImgArgumentException("[" cimg_appname "_math_parser] "
"CImg<%s>::%s: %s: %s arguments provided, in expression '%s'.",
pixel_type(),_cimg_mp_calling_function,s_op,
arg1<12?"Not enough":"Too much",s0);
}
_cimg_mp_check_type(opcode[2],1,2,0); // I
_cimg_mp_check_const_scalar(opcode[3],2,3); // wI
_cimg_mp_check_const_scalar(opcode[4],3,3); // hI
_cimg_mp_check_const_scalar(opcode[5],4,3); // dI
_cimg_mp_check_const_scalar(opcode[6],5,3); // sI
_cimg_mp_check_type(opcode[7],6,2,0); // K
_cimg_mp_check_const_scalar(opcode[8],7,3); // wK
_cimg_mp_check_const_scalar(opcode[9],8,3); // hK
_cimg_mp_check_const_scalar(opcode[10],9,3); // dK
_cimg_mp_check_const_scalar(opcode[11],10,3); // sK
_cimg_mp_check_type(opcode[12],11,1,0); // boundary_conditions
_cimg_mp_check_type(opcode[13],12,1,0); // is_normalized
_cimg_mp_check_const_scalar(opcode[14],13,1); // channel_mode
if (opcode[15]!=~0U) _cimg_mp_check_type(opcode[15],14,1,0); // xcenterView on GitHub (pinned to f788b534b4)
Solutions
- Provide all mandatory arguments (at least the 12 required slots), using explicit defaults for the ones you don't care about if the function accepts them.
- Trim any surplus trailing arguments beyond the documented maximum.
- Compare against the function's signature for the exact CImg version you link against.
- Use placeholder/default tokens (e.g. matching documented defaults) instead of omitting middle arguments.
Example fix
// before op(img, 8, ...) // only a few args -> 'Not enough arguments' // after op(img, 8, wI, hI, dI, sI, 1,1,1,1, 0, 1) // full 12-arg form
Defensive patterns
Strategy: validation
Validate before calling
if (args.size() < 12) throw std::runtime_error("opcode requires at least 12 arguments, got " + std::to_string(args.size()));
if (args.size() > MAX_SLOTS) throw std::runtime_error("too many arguments"); Try / catch
try {
img.fill(expr.c_str());
} catch (const CImgArgumentException& e) {
std::cerr << "argument count error: " << e.what() << std::endl;
} Prevention
- Supply explicit defaults for optional-but-positionally-required arguments
- Check the function signature for the exact CImg version in use
- Do not truncate pasted expressions
- Keep expression builders that emit all parameters explicitly
When it happens
Trigger: Invoking the corresponding expression function (an image-processing opcode taking >=12 parameters, e.g. a structured convolution/block operation) with fewer than the 12 mandatory arguments, or with more arguments than the opcode table can hold (overflow of optional trailing parameters).
Common situations: Porting an expression between CImg/G'MIC versions where the parameter list grew; omitting optional-looking-but-required middle parameters (they cannot be skipped without placeholders); pasting a truncated expression.
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
- [cimg_appname_math_parser] CImg<%s>::%s: %s: Too %s argument
- [" cimg_appname "_math_parser] CImg<%s>::%s: Function '%s()'
- [" cimg_appname "_math_parser] CImg<%s>::%s: Function '%s()'
- [" cimg_appname "_math_parser] CImg<%s>::%s: Undefined varia
- [" cimg_appname "_math_parser] CImg<%s>::%s: Unrecognized %s
AI-assisted analysis of Yalantis/uCrop@f788b534b4 (2026-09-08).
Data as JSON: /api/errors/dba7bfbff3e8c16a.
Report an issue: GitHub.