Yalantis/uCrop · error · CImgArgumentException

load_yuv(): Specified filename is (null).

Error message

load_yuv(): Specified filename is (null).

What it means

CImgList::_load_yuv() can read raw YUV video either from a FILE* or from a filename, but at least one must be provided. When both are null CImg throws CImgArgumentException because there is no data source.

Source

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

    }

    //! Load a list from an image sequence YUV file \newinstance.
    static CImgList<T> get_load_yuv(std::FILE *const file,
                                    const unsigned int size_x, const unsigned int size_y=1,
                                    const unsigned int chroma_subsampling=444,
                                    const unsigned int first_frame=0, const unsigned int last_frame=~0U,
                                    const unsigned int step_frame=1, const bool yuv2rgb=true) {
      return CImgList<T>().load_yuv(file,size_x,size_y,chroma_subsampling,
                                    first_frame,last_frame,step_frame,yuv2rgb);
    }

    CImgList<T>& _load_yuv(std::FILE *const file, const char *const filename,
                           const unsigned int size_x, const unsigned int size_y,
                           const unsigned int chroma_subsampling,
                           const unsigned int first_frame, const unsigned int last_frame,
                           const unsigned int step_frame, const bool yuv2rgb) {
      if (!filename && !file)
        throw CImgArgumentException(_cimglist_instance
                                    "load_yuv(): Specified filename is (null).",
                                    cimglist_instance);
      if (chroma_subsampling!=420 && chroma_subsampling!=422 && chroma_subsampling!=444)
        throw CImgArgumentException(_cimglist_instance
                                    "load_yuv(): Specified chroma subsampling %u is invalid, for file '%s'.",
                                    cimglist_instance,
                                    chroma_subsampling,filename?filename:"(FILE*)");
      const unsigned int
        cfx = chroma_subsampling==420 || chroma_subsampling==422?2:1,
        cfy = chroma_subsampling==420?2:1,
        nfirst_frame = first_frame<last_frame?first_frame:last_frame,
        nlast_frame = first_frame<last_frame?last_frame:first_frame,
        nstep_frame = step_frame?step_frame:1;

      if (!size_x || !size_y || size_x%cfx || size_y%cfy)
        throw CImgArgumentException(_cimglist_instance
                                    "load_yuv(): Specified dimensions (%u,%u) are invalid, for file '%s'.",
                                    cimglist_instance,

View on GitHub (pinned to f788b534b4)

Solutions

  1. Pass a valid filename string, or open the file yourself and pass the FILE*
  2. Validate the path (non-null, non-empty) before calling
  3. Fix the upstream source of the null path (env var, config, argv)

Example fix

// before
imgs.load_yuv(NULL, 640, 480); // no filename, no FILE*
// after
std::FILE* f = std::fopen("video.yuv", "rb");
imgs.load_yuv(f, 640, 480); // or: imgs.load_yuv("video.yuv", 640, 480);
Defensive patterns

Strategy: type-guard

Validate before calling

if (!filename && !file) { /* raise app-level 'no YUV source' error */ }

Type guard

bool hasYuvSource(const char* filename, std::FILE* file) { return filename != nullptr || file != nullptr; }

Try / catch

try { imgs.load_yuv(filename, w, h, 420); }
catch (CImgArgumentException& e) { fprintf(stderr, "no YUV source given: %s\n", e.what()); }

Prevention

When it happens

Trigger: Calling load_yuv(nullptr, ...) / _load_yuv(nullptr, nullptr, ...) with both the file pointer and filename null; passing a null char* filename and no open FILE*.

Common situations: Unset config value or failed lookup yielding a null path; calling the public load_yuv(filename,...) overload with a null string; refactored code that stopped opening the file before calling the internal loader.

Related errors


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