Yalantis/uCrop · error · CImgArgumentException
save_pfm(): Specified filename is (null).
Error message
save_pfm(): Specified filename is (null).
What it means
Raised by _save_pfm()'s argument-validation guard when both the output FILE* and the filename are null, so the library has nowhere to write the PFM data (the '(null)' text is its way of printing the missing filename). This is a generic sentinel error, not a filesystem failure; pass either an open file handle or a destination filename.
Solutions
- Provide a valid filename to save_pfm()
- Open a FILE* yourself and pass it to the FILE* overload
- Guard the call site: only call save_pfm when a destination exists
Example fix
// before if (saveHdr) img.save_pfm(hdrPath.empty() ? NULL : hdrPath.c_str()); // after if (saveHdr && !hdrPath.empty()) img.save_pfm(hdrPath.c_str());
Defensive patterns
Strategy: validation
Validate before calling
if (!file && (!filename || !*filename)) throw std::invalid_argument("save_pfm requires a filename or FILE*"); Type guard
bool hasDestination(std::FILE *f, const char *name) { return f != NULL || (name != NULL && name[0] != '\0'); } Try / catch
try { img.save_pfm(path.c_str()); } catch (CImgArgumentException &e) { /* handle */ } Prevention
- Only invoke optional-format saves when the destination is configured
- Validate empty strings as well as nulls
- Centralize output-path resolution in one checked helper
When it happens
Trigger: Calling save_pfm((std::FILE*)0) or _save_pfm(file,0) with a null file; forwarding a null filename through generic save-dispatch code.
Common situations: HDR pipeline where the PFM output path is optional but save_pfm is still invoked; fopen failure unchecked; null path from CLI/config defaults.
Related errors
- save_pnk(): Specified filename is (null).
- save_pnm(): Specified filename is (null).
- save_rgb(): Specified filename is (null).
- save_rgba(): Specified filename is (null).
- load_cimg(): Specified filename is (null).
AI-assisted analysis of Yalantis/uCrop@f788b534b4 (2026-09-08).
Data as JSON: /api/errors/4ea1c7a287979dc9.
Report an issue: GitHub.
Appendix: source
Thrown at ucrop/src/main/jni/CImg.h:62481
//! Save image as a PFM file.
/**
\param filename Filename, as a C-string.
**/
const CImg<T>& save_pfm(const char *const filename) const {
get_mirror('y')._save_pfm(0,filename);
return *this;
}
//! Save image as a PFM file \overloading.
const CImg<T>& save_pfm(std::FILE *const file) const {
get_mirror('y')._save_pfm(file,0);
return *this;
}
const CImg<T>& _save_pfm(std::FILE *const file, const char *const filename) const {
if (!file && !filename)
throw CImgArgumentException(_cimg_instance
"save_pfm(): Specified filename is (null).",
cimg_instance);
if (is_empty()) { cimg::fempty(file,filename); return *this; }
if (_depth>1)
cimg::warn(_cimg_instance
"save_pfm(): Instance is volumetric, only the first slice will be saved in file '%s'.",
cimg_instance,
filename?filename:"(FILE*)");
if (_spectrum>3)
cimg::warn(_cimg_instance
"save_pfm(): image instance is multispectral, only the three first channels will be saved "
"in file '%s'.",
cimg_instance,
filename?filename:"(FILE*)");
std::FILE *const nfile = file?file:cimg::fopen(filename,"wb");
const T
*ptr_r = data(0,0,0,0),View on GitHub (pinned to f788b534b4)