Yalantis/uCrop · error · CImgInstanceException
_cimg_instance "minabs(): Empty instance."
Error message
_cimg_instance "minabs(): Empty instance."
What it means
CImg<T>::minabs() returns a reference to the pixel with the smallest absolute value; on an empty instance there is no pixel to inspect, so CImgInstanceException is thrown instead of dereferencing invalid memory.
Solutions
- Check img.is_empty() before calling minabs()
- Fix the step that produced the empty image (load path, ROI bounds)
Example fix
// before
float v = img.minabs();
// after
if (!img.is_empty()) { float v = img.minabs(); } Defensive patterns
Strategy: validation
Validate before calling
if (!img.is_empty()) { ... img.minabs() ... } Try / catch
try { T v = img.minabs(); } catch (const CImgInstanceException& e) { /* handle empty */ } Prevention
- Validate non-emptiness before any min/max/abs statistics call
- Check that ROI computations never yield zero-size regions
When it happens
Trigger: Calling img.minabs() on a zero-size CImg (default-constructed, cleared, or produced by an empty crop/load).
Common situations: Signal/statistics code assuming the input was loaded; pipelines where a previous threshold or channel extraction emptied the buffer.
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
- atXYZC(): Empty instance.
- _cimg_instance "max(): Empty instance."
- _cimg_instance "min(): Empty instance."
- CImg< >:: () [%u]: cubic_atX(): Empty instance.
- CImg< >:: () [%u]: cubic_atX_p(): Empty instance.
AI-assisted analysis of Yalantis/uCrop@f788b534b4 (2026-09-08).
Data as JSON: /api/errors/cea41ba72d72bc03.
Report an issue: GitHub.
Appendix: source
Thrown at ucrop/src/main/jni/CImg.h:31775
//! Return a reference to the minimum pixel value \const.
const T& min() const {
if (is_empty())
throw CImgInstanceException(_cimg_instance
"min(): Empty instance.",
cimg_instance);
const T *ptr_min = _data;
T min_value = *ptr_min;
cimg_for(*this,ptrs,T) if (*ptrs<min_value) min_value = *(ptr_min=ptrs);
return *ptr_min;
}
//! Return a reference to the minimum pixel value in absolute value.
/**
**/
T& minabs() {
if (is_empty())
throw CImgInstanceException(_cimg_instance
"minabs(): Empty instance.",
cimg_instance);
T *ptr_minabs = _data;
T minabs_value = *ptr_minabs;
cimg_for(*this,ptrs,T) {
const T ma = cimg::abs(*ptrs);
if (ma<minabs_value) { minabs_value = ma; ptr_minabs = ptrs; }
}
return *ptr_minabs;
}
//! Return a reference to the minimum pixel value in absolute value \const.
const T& minabs() const {
if (is_empty())
throw CImgInstanceException(_cimg_instance
"minabs(): Empty instance.",
cimg_instance);
const T *ptr_minabs = _data;View on GitHub (pinned to f788b534b4)