Yalantis/uCrop · error · CImgArgumentException
%s
Error message
%s
What it means
Inside CImg's fill() expression machinery, when the fill expression fails to parse as a valid value sequence and an earlier parse error message was captured (is_error_expr), the library rethrows that specific parser message verbatim as a CImgArgumentException, prefixed with the instance description (_cimg_instance).
Source
Thrown at ucrop/src/main/jni/CImg.h:35182
}
#endif
}
}
mp.end();
if (result_end && mp.result_end) // Transfer result of the end() block if requested
result_end->assign(mp.result_end + (mp.result_end_dim?1:0),std::max(1U,mp.result_end_dim));
is_done = true;
} catch (CImgException& e) { CImg<charT>::string(e._message).move_to(is_error_expr); }
}
// Try to fill values according to a value sequence.
if (!is_done && mode&1) is_done = !_fill_from_values(expression,repeat_values);
if (!is_done) {
cimg::exception_mode(excmode);
if (is_error_expr) throw CImgArgumentException(_cimg_instance
"%s",
cimg_instance,is_error_expr._data);
else throw CImgArgumentException(_cimg_instance
"%s(): Invalid sequence of filling values '%s'.",
cimg_instance,calling_function,expression);
}
cimg::exception_mode(excmode);
cimg_abort_test;
return *this;
}
//! Fill sequentially pixel values according to a given expression \newinstance.
CImg<T> get_fill(const char *const expression, const bool repeat_values, const bool allow_formula=true,
CImgList<T> *const list_images=0) const {
return (+*this)._fill(expression,repeat_values,allow_formula?3:1,list_images,"fill",this,0);
}
//! Fill sequentially pixel values according to a value sequence, given as a string.View on GitHub (pinned to f788b534b4)
Solutions
- Check the embedded message (it is substituted for %s) for the exact parser complaint and fix the expression syntax
- Validate expressions against CImg's fill() formula grammar before calling
- Test the expression on a tiny dummy image in a try/catch during development
- Sanitize/reject user-supplied expressions with a pre-parse validator
Example fix
// before
img.fill("x*y?%/2"); // malformed expression
// after
img.fill("x*y"); // valid fill expression Defensive patterns
Strategy: try-catch
Try / catch
try { img.fill(expr.c_str()); } catch (CImgArgumentException& e) { /* e.what() embeds the parser message; log and reject expression */ } Prevention
- Test fill expressions on a dummy image before production use
- Restrict user-supplied expressions to a validated subset
- Pin CImg version and consult its fill() grammar docs
When it happens
Trigger: Calling fill("expression") where the expression is malformed such that the expression parser itself records an error string (is_error_expr non-empty) — e.g. invalid operators, bad variable names, or truncated formulas in the mini formula language.
Common situations: Typos in fill() math expressions; expressions copied from docs of a different CImg version; user-supplied expression strings passed through without validation; locale/whitespace issues breaking the parser.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- %s(): Invalid sequence of filling values '%s'.
- [" cimg_appname "_math_parser] CImg<%s>::%s: Unterminated st
- [" cimg_appname "_math_parser] CImg<%s>::%s: Unbalanced pare
- "[" cimg_appname "_math_parser] CImg<%s>: Function 'polygon(
- "[" cimg_appname "_math_parser] CImg<%s>: Function 'polygon(
AI-assisted analysis of Yalantis/uCrop@f788b534b4 (2026-09-08).
Data as JSON: /api/errors/9c81f875504c923b.
Report an issue: GitHub.