Yalantis/uCrop · error · CImgArgumentException

[" cimg_appname "_math_parser] CImg<

Error message

[" cimg_appname "_math_parser] CImg<%s>::%s: %s: Warp vector size (%lu values) and its specified geometry (%u,%u,%u,%u) (%lu values) do not match.

What it means

Companion check of the same warp opcode: the warp vector's value count (max 1) must equal the product of its four geometry dims opcode[6..9]. When the warp coordinates vector and its declared (w,h,d,s) geometry disagree, the VM throws with both counts.

Solutions

  1. Ensure width*height*depth*spectrum of the warp geometry equals the warp vector's actual value count (or 1 if empty).
  2. Rebuild the warp vector with the correct number of coordinates for the target geometry.
  3. Update the geometry arguments in the expression to match the warp vector you actually pass.

Example fix

// before: warp vector has 8 values, dims say 4
'warp(input,warpvec,2,2,1,1)'
// after
'warp(input,warpvec,8,1,1,1)'
Defensive patterns

Strategy: validation

Validate before calling

if (w*h*d*s !== Math.max(1, warpVec.length)) throw new Error('Warp geometry ' + w*h*d*s + ' != size ' + Math.max(1, warpVec.length));

Try / catch

try { img.eval(expr); } catch (e) { if (/Warp vector size .* do not match/.test(e.message)) { /* rebuild warp vector for the declared geometry */ } else throw e; }

Prevention

When it happens

Trigger: Executing a warp expression where the warp-coordinate vector was built with a different size than the geometry stored in opcode slots 6-9, e.g. 8 values with dims (2,2,1,1)=4.

Common situations: Changing interpolation dimensions without regenerating the warp vector; reusing a warp vector computed for another image size; hand-editing dims in a serialized expression.

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

Appendix: source

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

              arg3 = (unsigned int)mem[opcode[1]]; opcode[1] = arg3;
              arg4 = (unsigned int)mem[opcode[2]]; opcode[2] = arg4;
              arg5 = (unsigned int)mem[opcode[3]]; opcode[3] = arg5;
              arg6 = (unsigned int)mem[opcode[4]]; opcode[4] = arg6;
              if (arg3*arg4*arg5*arg6!=std::max(1U,p1)) {
                _cimg_mp_strerr;
                throw CImgArgumentException("[" cimg_appname "_math_parser] "
                                            "CImg<%s>::%s: %s: Input vector size (%lu values) and its specified "
                                            "geometry (%u,%u,%u,%u) (%lu values) do not match.",
                                            pixel_type(),_cimg_mp_calling_function,s_op,
                                            std::max(p1,1U),arg3,arg4,arg5,arg6,(ulongT)arg3*arg4*arg5*arg6);
              }
              arg3 = (unsigned int)mem[opcode[6]]; opcode[6] = arg3;
              arg4 = (unsigned int)mem[opcode[7]]; opcode[7] = arg4;
              arg5 = (unsigned int)mem[opcode[8]]; opcode[8] = arg5;
              arg6 = (unsigned int)mem[opcode[9]]; opcode[9] = arg6;
              if (arg3*arg4*arg5*arg6!=std::max(1U,p2)) {
                _cimg_mp_strerr;
                throw CImgArgumentException("[" cimg_appname "_math_parser] "
                                            "CImg<%s>::%s: %s: Warp vector size (%lu values) and its specified "
                                            "geometry (%u,%u,%u,%u) (%lu values) do not match.",
                                            pixel_type(),_cimg_mp_calling_function,s_op,
                                            std::max(p2,1U),arg3,arg4,arg5,arg6,(ulongT)arg3*arg4*arg5*arg6);
              }
              pos = vector(arg3*arg4*arg5*(unsigned int)opcode[4]);
              opcode.resize(1,15,1,1,0,0,0,1);
              opcode[0] = (ulongT)mp_warp;
              opcode[1] = (ulongT)pos;
              opcode.move_to(code);
              return_comp = true;
              _cimg_mp_return(pos);
            }

            if (!std::strncmp(ss,"wave(",5)) { // Wave function
              _cimg_mp_op("Function 'wave()'");
              s1 = ss5; while (s1<se1 && (*s1!=',' || level[s1 - expr._data]!=clevel1)) ++s1;
              arg1 = compile(ss5,s1,depth1,0,block_flags); // x

View on GitHub (pinned to f788b534b4)