Yalantis/uCrop · error · CImgArgumentException
load_jxl(): Specified filename is (null).
Error message
load_jxl(): Specified filename is (null).
What it means
Raised by _load_jxl()'s guard when both the FILE* and the filename argument are null, i.e. no source for the JPEG XL image was provided ('(null)' is how the library reports the missing filename). It fires immediately, before the JXL decoder is invoked; supply a valid filename or an open FILE*.
Source
Thrown at ucrop/src/main/jni/CImg.h:57127
//! Load image from a JPEG XL file \newinstance.
static CImg<T> get_load_jxl(const char *const filename) {
return CImg<T>().load_jxl(filename);
}
//! Load image from a JPEG XL file \overloading.
CImg<T>& load_jxl(std::FILE *const file) {
return _load_jxl(file,0);
}
//! Load image from a JPEG XL file \newinstance.
static CImg<T> get_load_jxl(std::FILE *const file) {
return CImg<T>().load_jxl(file);
}
CImg<T>& _load_jxl(std::FILE *const file, const char *const filename) {
if (!file && !filename)
throw CImgArgumentException(_cimg_instance
"load_jxl(): Specified filename is (null).",
cimg_instance);
#ifndef cimg_use_jxl
if (file)
throw CImgIOException(_cimg_instance
"load_jxl(): Unable to load data from '(FILE*)' unless libjxl is enabled.",
cimg_instance);
else return load_other(filename);
#else
const char *nfilename = filename;
std::FILE *nfile = file?file:cimg::fopen(nfilename,"rb");
const long dataSize = cimg::fsize(nfile);
if (dataSize<=0) {
cimg::fclose(nfile);
throw CImgIOException(_cimg_instance
"load_jxl(): Failed to get file size '%s'.",
cimg_instance,View on GitHub (pinned to f788b534b4)
Solutions
- Ensure the filename or FILE* is valid before calling load_jxl
- Check fopen's return value before passing the handle
- Verify path strings crossing JNI are non-null
- Catch CImgArgumentException during development to catch call-site bugs
Example fix
// before
std::FILE* f = fopen(path,"rb");
img.load_jxl(f, path);
// after
if (!path) throw std::invalid_argument("jxl path is null");
std::FILE* f = fopen(path,"rb");
if (!f) throw std::runtime_error("cannot open jxl file");
img.load_jxl(f, path); Defensive patterns
Strategy: type-guard
Validate before calling
if (!filename || !*filename) throw std::invalid_argument("filename required"); Type guard
bool hasJxlSource(std::FILE* file, const char* filename) { return file != nullptr || (filename != nullptr && filename[0] != '\0'); } Try / catch
try { img.load_jxl(file, filename); }
catch (CImgArgumentException& e) { log("null jxl source: %s", e.what()); } Prevention
- Check fopen results before passing handles
- Validate paths at native boundaries
- Initialize source pointers at declaration
- Add unit tests covering null-source calls
When it happens
Trigger: Calling load_jxl(NULL, NULL), or passing a null filename where a FILE* was expected to be opened earlier.
Common situations: Unchecked fopen failure, null path crossing a native/JNI boundary, uninitialized variables.
Related errors
- load_jpeg(): Specified filename is (null).
- load_jxl(): Unable to load data from '(FILE*)' unless libjxl
- load_magick(): Specified filename is (null).
- load_pfm(): Specified filename is (null).
- load_rgb(): Specified filename is (null).
AI-assisted analysis of Yalantis/uCrop@f788b534b4 (2026-09-08).
Data as JSON: /api/errors/1d0f47bd52fb27da.
Report an issue: GitHub.