Yalantis/uCrop · error · CImgArgumentException

"[" cimg_appname "_math_parser] CImg<%s>: Function 'ellipse(

Error message

"[" cimg_appname "_math_parser] CImg<%s>: Function 'ellipse()': Invalid arguments '#%u%s%s'. "

What it means

Same dispatch failure as the plain-arguments variant of ellipse(), but here an image selector '#ind' was provided. The parser collected the trailing arguments into a vector, failed to match a supported ellipse() overload for that image, and reports the arguments after the '#ind,' prefix.

Source

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

                    }
                  }
                }
              }
            }
          }
        }
        if (!is_invalid_arguments) {
          if (is_outlined) img.draw_ellipse(x0,y0,r1,r2,angle,color._data,opacity,pattern);
          else img.draw_ellipse(x0,y0,r1,r2,angle,color._data,opacity);
        } else {
          CImg<doubleT> args(i_end - 4);
          cimg_forX(args,k) args[k] = _mp_arg(4 + k);
          if (ind==~0U)
            throw CImgArgumentException("[" cimg_appname "_math_parser] CImg<%s>: Function 'ellipse()': "
                                        "Invalid arguments '%s'. ",
                                        mp.imgin.pixel_type(),args.value_string()._data);
          else
            throw CImgArgumentException("[" cimg_appname "_math_parser] CImg<%s>: Function 'ellipse()': "
                                        "Invalid arguments '#%u%s%s'. ",
                                        mp.imgin.pixel_type(),ind,args._width?",":"",args.value_string()._data);
        }
        return cimg::type<double>::nan();
      }

      static double mp_epoch(_cimg_math_parser& mp) {
        unsigned int
          year = (unsigned int)mp.opcode[2]==~0U?~0U:(unsigned int)std::max(_mp_arg(2),1900.),
          month = (unsigned int)mp.opcode[3]==~0U?~0U:(unsigned int)cimg::cut(_mp_arg(3),1.,12.),
          day = (unsigned int)mp.opcode[4]==~0U?~0U:(unsigned int)cimg::cut(_mp_arg(4),1.,31.),
          hour = (unsigned int)mp.opcode[5]==~0U?~0U:(unsigned int)cimg::cut(_mp_arg(5),0.,23.),
          minute = (unsigned int)mp.opcode[6]==~0U?~0U:(unsigned int)cimg::cut(_mp_arg(6),0.,59.),
          second = (unsigned int)mp.opcode[7]==~0U?~0U:(unsigned int)cimg::cut(_mp_arg(7),0.,60.);
        if (year==~0U && month==~0U && day==~0U &&
            hour==~0U && minute==~0U && second==~0U) // No argument -> current date
          return (double)cimg::epoch(cimg::date(0),cimg::date(1),cimg::date(2),
                                     cimg::date(4),cimg::date(5),cimg::date(6));

View on GitHub (pinned to f788b534b4)

Solutions

  1. Match the documented ellipse(#ind,x,y,r1,r2,angle,color[,opacity[,pattern]]) argument list exactly.
  2. Remove unexpected extra arguments or add missing ones (the message prints the offending argument vector).
  3. Verify against the CImg version in use; adjust the expression after upgrades.
  4. If arguments are dynamic, assert their count before building the call.

Example fix

// before: extra stray argument
 ellipse(#0,x,y,r1,r2,angle,opacity,extra)
// after
 ellipse(#0,x,y,r1,r2,angle,opacity)
Defensive patterns

Strategy: validation

Validate before calling

// Validate the argument list following '#ind,' before evaluation
function checkEllipseIndArgs(ind, args) { if (![5,6,7,8].includes(args.length)) throw new Error('ellipse(#' + ind + ') invalid arity: ' + args.length); }

Type guard

function isValidEllipseCall(ind, args) { return Number.isInteger(ind) && ind >= 0 && [5,6,7,8].includes(args.length); }

Try / catch

try { evalMath(expr); } catch (e) { if (String(e).includes("Function 'ellipse()'") && String(e).includes('#')) { console.error('ellipse() with selector rejected args:', e.message); } else throw e; }

Prevention

When it happens

Trigger: Calling ellipse(#ind,...) with an argument count/types that match no supported overload (e.g. wrong radii/angle/color arity) for image ind.

Common situations: Script typos in argument lists; version drift between G'MIC/CImg releases changing ellipse() overloads; accidentally passing extra positional values.

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/f898fcae474c6cc9. Report an issue: GitHub.