Yalantis/uCrop · error · CImgInstanceException
select(): Empty instance.
Error message
select(): Empty instance.
What it means
CImgList::_select() (backing select() family for interactive feature selection in a display) throws CImgInstanceException when the list is empty — there are no images to visualize or pick from. It is an instance-state error, not an argument error.
Solutions
- Check list.is_empty() / list.size() > 0 before calling select() and bail out with a message
- Ensure the list was actually loaded/populated (verify the load call succeeded)
- Initialize the CImgDisplay and list from a valid data source before interaction
Example fix
// before
disp.select(list); // throws on empty list
// after
if (!list.is_empty()) {
CImg<int> sel = disp.select(list);
} else {
std::fprintf(stderr, "nothing to select from\n");
} Defensive patterns
Strategy: validation
Validate before calling
if (list.is_empty()) { /* report and skip interactive selection */ } Try / catch
try { sel = disp.select(list); } catch (const CImgInstanceException& e) { std::fprintf(stderr, "empty list\n"); } Prevention
- Verify the load pipeline populated the list before opening UI
- Check is_empty() after filtering steps
- Fail early with a clear message when input data is missing
When it happens
Trigger: Calling list.select(disp) (or the feature/axis variants) on a CImgList whose size is 0, typically after a failed or skipped load.
Common situations: Load returned an empty list (missing file) and the interactive selection was started anyway; a filter step removed all images before selection; wrong variable passed to select().
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- atXYZC(): Empty instance.
- _cimg_instance "max(): Empty instance."
- _cimg_instance "min(): Empty instance."
- _cimg_instance "minabs(): Empty instance."
- CImg< >:: () [%u]: cubic_atX(): Empty instance.
AI-assisted analysis of Yalantis/uCrop@f788b534b4 (2026-09-08).
Data as JSON: /api/errors/530443ea8d8f8016.
Report an issue: GitHub.
Appendix: source
Thrown at ucrop/src/main/jni/CImg.h:66319
\param feature_type Can be \c false to select a single image, or \c true to select a sublist.
\param axis Axis along whom images are appended for visualization.
\param align Alignment setting when images have not all the same size.
\param exit_on_anykey Exit function when any key is pressed.
\return A one-column vector containing the selected image indexes.
**/
CImg<intT> get_select(const char *const title, const bool feature_type=true,
const char axis='x', const float align=0,
const bool exit_on_anykey=false) const {
CImgDisplay disp;
return _select(disp,title,feature_type,axis,align,exit_on_anykey,0,false,false,false);
}
CImg<intT> _select(CImgDisplay &disp, const char *const title, const bool feature_type,
const char axis, const float align, const bool exit_on_anykey,
const unsigned int orig, const bool resize_disp,
const bool exit_on_rightbutton, const bool exit_on_wheel) const {
if (is_empty())
throw CImgInstanceException(_cimglist_instance
"select(): Empty instance.",
cimglist_instance);
// Create image correspondence table and get list dimensions for visualization.
CImgList<uintT> _indices;
unsigned int max_width = 0, max_height = 0, sum_width = 0, sum_height = 0;
cimglist_for(*this,l) {
const CImg<T>& img = _data[l];
const unsigned int
w = CImgDisplay::_fitscreen(img._width,img._height,img._depth,128,-85,false),
h = CImgDisplay::_fitscreen(img._width,img._height,img._depth,128,-85,true);
if (w>max_width) max_width = w;
if (h>max_height) max_height = h;
sum_width+=w; sum_height+=h;
if (axis=='x') CImg<uintT>(w,1,1,1,(unsigned int)l).move_to(_indices);
else CImg<uintT>(h,1,1,1,(unsigned int)l).move_to(_indices);
}
const CImg<uintT> indices0 = _indices>'x';View on GitHub (pinned to f788b534b4)