Yalantis/uCrop · error · CImgInstanceException
min(): %s.
Error message
min(): %s.
What it means
CImgList<T>::min() computes the minimum pixel value across all images in the list. If every image in the list is empty (no pixel buffer) the scan finds no valid pointer and the library throws CImgInstanceException with "min(): %s." where %s is "List of empty images" or "Empty instance" (ucrop/src/main/jni/CImg.h:65536). Min/max are undefined on no data, so the library refuses to return a bogus value.
Source
Thrown at ucrop/src/main/jni/CImg.h:65536
//-------------------------------------
//
//! \name Mathematical Functions
//@{
//-------------------------------------
//! Return a reference to the minimum pixel value of the instance list.
/**
**/
T& min() {
bool is_all_empty = true;
T *ptr_min = 0;
cimglist_for(*this,l) if (!_data[l].is_empty()) {
ptr_min = _data[l]._data;
is_all_empty = false;
break;
}
if (is_all_empty)
throw CImgInstanceException(_cimglist_instance
"min(): %s.",
_data?"List of empty images":"Empty instance",
cimglist_instance);
T min_value = *ptr_min;
cimglist_for(*this,l) {
const CImg<T>& img = _data[l];
cimg_for(img,ptrs,T) if (*ptrs<min_value) min_value = *(ptr_min=ptrs);
}
return *ptr_min;
}
//! Return a reference to the minimum pixel value of the instance list \const.
const T& min() const {
bool is_all_empty = true;
T *ptr_min = 0;
cimglist_for(*this,l) if (!_data[l].is_empty()) {
ptr_min = _data[l]._data;
is_all_empty = false;View on GitHub (pinned to f788b534b4)
Solutions
- Before calling min(), verify the list contains at least one non-empty image (loop and check !img.is_empty()).
- Fix the upstream image loading/resizing so images actually contain pixels before statistics are computed.
- Catch CImgInstanceException around the min() call and handle the empty-data case with a fallback value.
- If the list is legitimately allowed to be empty, branch on is_empty() and skip the statistic entirely.
Example fix
// before
const T mn = list.min();
// after
bool any = false;
for (unsigned int l = 0; l < list.size(); ++l) if (!list[l].is_empty()) { any = true; break; }
if (!any) return; // or substitute a default
const T mn = list.min(); Defensive patterns
Strategy: validation
Validate before calling
bool any = false; for (unsigned int l = 0; l < list.size(); ++l) if (!list[l].is_empty()) { any = true; break; } if (!any) { /* skip statistic */ } Type guard
static inline bool hasNonEmptyImage(const CImgList<T>& l) { cimglist_for(l, i) if (!l[i].is_empty()) return true; return false; } Try / catch
try { mn = list.min(); } catch (CImgInstanceException& e) { mn = defaultValue; } Prevention
- Guard all extremum/statistics calls with a non-empty-image check.
- Fail loudly at load time so empty batches never reach analysis code.
- Skip normalization steps when input data is absent rather than computing garbage extrema.
- Log image counts/dimensions when building the list.
When it happens
Trigger: Calling the const/non-const min() on a CImgList where _data is null (empty list) or where every element CImg is empty (0-size dimensions), detected when the is_all_empty flag stays true after the cimglist_for scan.
Common situations: Computing statistics over a batch of images after all loads failed; a resizing/crop step that produced zero-sized images; calling min() on a default-constructed list used as an accumulator.
Understand the failure class
Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.
Related errors
AI-assisted analysis of Yalantis/uCrop@f788b534b4 (2026-09-08).
Data as JSON: /api/errors/ffb7ad6c93b203c8.
Report an issue: GitHub.