Method: Magick::Image#number_colors

Defined in:
ext/RMagick/rmimage.cpp

#number_colorsInteger

Return the number of unique colors in the image.

Returns:

  • (Integer)

    number of unique colors



10073
10074
10075
10076
10077
10078
10079
10080
10081
10082
10083
10084
10085
10086
10087
10088
10089
10090
# File 'ext/RMagick/rmimage.cpp', line 10073

VALUE
Image_number_colors(VALUE self)
{
    Image *image;
    ExceptionInfo *exception;
    size_t n = 0;

    image = rm_check_destroyed(self);
    exception = AcquireExceptionInfo();

    GVL_STRUCT_TYPE(GetNumberColors) args = { image, NULL, exception };
    n = (size_t)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(GetNumberColors), &args);
    CHECK_EXCEPTION();

    DestroyExceptionInfo(exception);

    return ULONG2NUM(n);
}