Yalantis/uCrop · error · CImgArgumentException
save_jxl(): Specified filename is (null).
Error message
save_jxl(): Specified filename is (null).
What it means
CImg's save_jxl() requires a destination filename; _save_jxl throws CImgArgumentException immediately when the filename pointer is null. JPEG XL saving in this code path is filename-based only — there is no FILE* overload to fall back on.
Solutions
- Pass a concrete path with a .jxl extension: img.save_jxl("out.jxl").
- Validate the filename (non-null, non-empty) before calling save_jxl and fail early.
- Ensure the variable holding the path is actually initialized before the save call.
Example fix
// before
const char *out = config.outputPath; // may be null
img.save_jxl(out);
// after
if (!config.outputPath || !*config.outputPath) throw std::invalid_argument("outputPath required");
img.save_jxl(config.outputPath); Defensive patterns
Strategy: validation
Validate before calling
if (!outPath || !*outPath) {
throw std::invalid_argument("jxl output path is required");
}
img.save_jxl(outPath); Prevention
- Validate output paths at configuration load time.
- Never store filenames as raw pointers that can be null.
- Check strlen/emptiness before format-specific save calls.
When it happens
Trigger: Calling img.save_jxl(nullptr) or passing a null/empty-derived filename variable to _save_jxl.
Common situations: Filenames computed at runtime (from user input, config, or string operations) that end up null; also calling internal overloads directly with an uninitialized char*.
Related errors
- cimg::ftype(): Specified filename is (null).
- cimg::load_network(): Specified destination string is…
- cimg::load_network(): Specified URL is (null).
- load_analyze(): Specified filename is (null).
- load_ascii(): Specified filename is (null).
AI-assisted analysis of Yalantis/uCrop@f788b534b4 (2026-09-08).
Data as JSON: /api/errors/84664b6c997ef54b.
Report an issue: GitHub.
Appendix: source
Thrown at ucrop/src/main/jni/CImg.h:61766
#endif
}
//! Save image as a JPEG XL file.
/**
\param filename Filename, as a C-string.
\param distance Sets the level for lossy compression: lower = higher quality.
Range: 0 .. 25. 0.0 = mathematically lossless
\param bytes_per_pixel Force the number of bytes per pixels for the saving, when possible.
**/
const CImg<T>& save_jxl(const char *const filename, const float distance=1.0f,
const unsigned int bytes_per_pixel=0) const {
return _save_jxl(filename,distance,bytes_per_pixel);
}
const CImg<T>& _save_jxl(const char *const filename, const float distance=1.0f,
const unsigned int bytes_per_pixel=0) const {
if (!filename)
throw CImgArgumentException(_cimg_instance
"save_jxl(): Specified filename is (null).",
cimg_instance);
if (_spectrum > 4)
throw CImgArgumentException(_cimg_instance
"save_jxl(): JPEG XL only supports at most 4 channels.",
cimg_instance);
double stmin, stmax = (double)max_min(stmin);
if (stmin<0 || (bytes_per_pixel==1 && stmax>=256) || stmax>=65536)
cimg::warn(_cimg_instance
"save_jxl(): Instance has pixel values in [%g,%g], probable type overflow in file '%s'.",
cimg_instance,
stmin,stmax,filename);
if (bytes_per_pixel>2 || sizeof(T)<bytes_per_pixel)
throw CImgArgumentException(_cimg_instance
"save_jxl(): bytes_per_pixel must be in [0, 2] and less than or equal to sizeof(T)",
cimg_instance);
if (_depth>1)
cimg::warn(_cimg_instanceView on GitHub (pinned to f788b534b4)