Yalantis/uCrop · error · CImgArgumentException
save_tiff(): Specified filename is (null).
Error message
save_tiff(): Specified filename is (null).
What it means
Raised by save_tiff()'s validation path when both the output FILE* and the filename are null, so no write target exists for the TIFF data; the message shows the filename argument as the literal '(null)'. This is the standard CImg sentinel guard for missing I/O arguments, not a libtiff encoding error — supply a filename or an open file handle.
Solutions
- Pass a non-null filename string to save_tiff()
- Validate the path before calling save_tiff()
- Skip or branch the call when no TIFF output was requested
Example fix
// before
img.save_tiff(tiffName); // tiffName may be NULL
// after
if (tiffName) img.save_tiff(tiffName);
else cimg::warn("no TIFF output requested, skipping"); Defensive patterns
Strategy: validation
Validate before calling
if (!filename || !*filename) throw std::invalid_argument("save_tiff requires a filename"); Type guard
bool isValidFilename(const char *name) { return name != NULL && name[0] != '\0'; } Try / catch
try { img.save_tiff(path.c_str()); } catch (CImgArgumentException &e) { /* missing destination */ } Prevention
- TIFF has no FILE* overload — always supply a filename string
- Check optional config fields before unconditionally saving
- Avoid null char* in JNI glue; use checked jstring conversion
When it happens
Trigger: Calling img.save_tiff(NULL) or save_tiff(someNullCharPtr); passing a null const char* from a config/variable that was never set; generic save() with an empty/null resolved name routed to the TIFF path.
Common situations: Batch exporters where the TIFF output field is optional but the call is unconditional; null from string::c_str misuse of a released buffer; uninitialized char* in C-style glue code (JNI).
Related errors
- load_cimg(): Specified filename is (null).
- load_tiff(): Specified filename is (null).
- save_pfm(): Specified filename is (null).
- save_pnk(): Specified filename is (null).
- save_pnm(): Specified filename is (null).
AI-assisted analysis of Yalantis/uCrop@f788b534b4 (2026-09-08).
Data as JSON: /api/errors/286761b517e7dbea.
Report an issue: GitHub.
Appendix: source
Thrown at ucrop/src/main/jni/CImg.h:62715
24=PIXARFILM | 25=PIXARLOG | 26=SGILOG | 27=SGILOG24 | 28=T43 | 29=T85 | 30=THUNDERSCAN |
31=WEBP | 32=ZSTD }</tt>
\param[out] voxel_size Voxel size, to be stored in the filename.
\param[out] description Description, to be stored in the filename.
\param use_bigtiff Allow to save big tiff files (>4Gb).
\note
- libtiff support is enabled by defining the precompilation
directive \c cimg_use_tiff.
- When libtiff is enabled, 2D and 3D (multipage) several
channel per pixel are supported for
<tt>char,uchar,short,ushort,float</tt> and \c double pixel types.
- If \c cimg_use_tiff is not defined at compile time the
function uses CImg<T>&save_other(const char*).
**/
const CImg<T>& save_tiff(const char *const filename, const unsigned int compression_type=0,
const float *const voxel_size=0, const char *const description=0,
const bool use_bigtiff=true) const {
if (!filename)
throw CImgArgumentException(_cimg_instance
"save_tiff(): Specified filename is (null).",
cimg_instance);
if (is_empty()) { cimg::fempty(0,filename); return *this; }
#ifdef cimg_use_tiff
const bool
_use_bigtiff = use_bigtiff && sizeof(ulongT)>=8 && size()*sizeof(T)>=1UL<<31; // No bigtiff for small images
TIFF *tif = TIFFOpen(filename,_use_bigtiff?"w8":"w4");
if (tif) {
double val_min, val_max = (double)max_min(val_min);
cimg_forZ(*this,z) _save_tiff(tif,z,z,compression_type,voxel_size,description,val_min,val_max);
TIFFClose(tif);
} else throw CImgIOException(_cimg_instance
"save_tiff(): Failed to open file '%s' for writing.",
cimg_instance,
filename);
return *this;
#elseView on GitHub (pinned to f788b534b4)