ImageMagick: MagickCore, C API for ImageMagick: Count the Colors in an Image
Author: ImageMagick Studio LLC
Description: ImageMagick® is a software suite to create, edit, and compose bitmap images. It can read, convert and write images in a variety of formats (about 100) including GIF, JPEG, JPEG-2000, PNG, PDF, PhotoCD, TIFF, and DPX. Use ImageMagick to translate, flip, mirror, rotate, scale, shear and transform images, adjust image colors, apply various special effects, or draw text, lines, polygons, ellipses and Bézier curves. ImageMagick is free software delivered as a ready-to-run binary distribution or as source code that you can freely use, copy, modify, and distribute. Its license is compatible with the GPL. It runs on all major operating systems. The functionality of ImageMagick is typically utilized from the command line or you can use the features from programs written in your favorite programming language. Choose from these interfaces: MagickCore (C), MagickWand (C), ChMagick (Ch), Magick++ (C++), JMagick (Java), L-Magick (Lisp), PascalMagick (Pascal), PerlMagick (Perl), MagickWand for PHP (P [cell cut: 1167 characters, first 1000 kept]
Keywords: magickcore, c, api, for, imagemagick:, count, the, colors, in, an, image, ImageMagick, ImageMagic, MagickCore, MagickWand, PerlMagick, Magick++, RMagick, PythonMagick, JMagick, TclMagick, Image, Magick, Magic, Wand

## GetColorInfoList GetColorInfoList() returns any colors that match the specified pattern. The format of the GetColorInfoList function is:
      const ColorInfo **GetColorInfoList(const char *pattern,
        unsigned long *number_colors,ExceptionInfo *exception)
A description of each parameter follows: ##### pattern Specifies a pointer to a text string containing a pattern. ##### number_colors This integer returns the number of colors in the list. ##### exception Return any errors or warnings in this structure. ## GetColorList GetColorList() returns any colors that match the specified pattern. The format of the GetColorList function is:
      char **GetColorList(const char *pattern,unsigned long *number_colors,
        ExceptionInfo *exception)
A description of each parameter follows: ##### pattern Specifies a pointer to a text string containing a pattern. ##### number_colors This integer returns the number of colors in the list. ##### exception Return any errors or warnings in this structure. ## GetImageHistogram GetImageHistogram() returns the unique colors in an image. The format of the GetImageHistogram method is:
      unsigned long GetImageHistogram(const Image *image,
        unsigned long *number_colors,ExceptionInfo *exception)
A description of each parameter follows. ##### image The image. ##### file Write a histogram of the color distribution to this file handle. ##### exception Return any errors or warnings in this structure. ## GetMagickPixelPacket GetMagickPixelPacket() initializes the MagickPixelPacket structure. The format of the GetMagickPixelPacket method is:
      GetMagickPixelPacket(const Image *image,MagickPixelPacket *pixel)
A description of each parameter follows: ##### image The image. ##### pixel Specifies a pointer to a PixelPacket structure. ## GetNumberColors GetNumberColors() returns the number of unique colors in an image. The format of the GetNumberColors method is:
      unsigned long GetNumberColors(const Image *image,FILE *file,
        ExceptionInfo *exception)
A description of each parameter follows. ##### image The image. ##### file Write a histogram of the color distribution to this file handle. ##### exception Return any errors or warnings in this structure. ## IsGrayImage IsGrayImage() returns MagickTrue if all the pixels in the image have the same red, green, and blue intensities. The format of the IsGrayImage method is:
      MagickBooleanType IsGrayImage(const Image *image,
        ExceptionInfo *exception)
A description of each parameter follows: ##### image The image. ##### exception Return any errors or warnings in this structure. ## IsMonochromeImage IsMonochromeImage() returns MagickTrue if all the pixels in the image have the same red, green, and blue intensities and the intensity is either 0 or QuantumRange. The format of the IsMonochromeImage method is:
      MagickBooleanType IsMonochromeImage(const Image *image,
        ExceptionInfo *exception)
A description of each parameter follows: ##### image The image. ##### exception Return any errors or warnings in this structure. ## IsOpaqueImage IsOpaqueImage() returns MagickTrue if none of the pixels in the image have an opacity value other than opaque (0). The format of the IsOpaqueImage method is:
      MagickBooleanType IsOpaqueImage(const Image *image,
        ExceptionInfo *exception)
A description of each parameter follows: ##### image The image. ##### exception Return any errors or warnings in this structure. ## IsPaletteImage IsPaletteImage() returns MagickTrue if the image is PseudoClass and has 256 unique colors or less. The format of the IsPaletteImage method is:
      MagickBooleanType IsPaletteImage(const Image *image,
        ExceptionInfo *exception)
A description of each parameter follows. ##### image The image. ##### exception Return any errors or warnings in this structure. ## ListColorInfo ListColorInfo() lists color names to the specified file. Color names are a convenience. Rather than defining a color by its red, green, and blue intensities just use a color name such as white, blue, or yellow. The format of the ListColorInfo method is:
      MagickBooleanType ListColorInfo(FILE *file,ExceptionInfo *exception)
A description of each parameter follows. ##### file List color names to this file handle. ##### exception Return any errors or warnings in this structure. ## LoadColorList LoadColorList() loads one or more color configuration file which provides a mapping between color attributes and a color name. The format of the LoadColorLists method is:
      MagickBooleanType LoadColorLists(const char *filename,
        ExceptionInfo *exception)
A description of each parameter follows: ##### filename The font file name. ##### exception Return any errors or warnings in this structure. ## QueryColorDatabase QueryColorDatabase() returns the red, green, blue, and opacity intensities for a given color name. The format of the QueryColorDatabase method is:
      MagickBooleanType QueryColorDatabase(const char *name,PixelPacket *color,
        ExceptionInfo *exception)
A description of each parameter follows: ##### name The color name (e.g. white, blue, yellow). ##### color The red, green, blue, and opacity intensities values of the named color in this structure. ##### exception Return any errors or warnings in this structure. ## QueryColorname QueryColorname() returns a named color for the given color intensity. If an exact match is not found, a rgb() color is returned instead. The format of the QueryColorname method is:
      MagickBooleanType QueryColorname(const Image *image,
        const PixelPacket *color,const ComplianceType compliance,char *name,
        ExceptionInfo *exception)
A description of each parameter follows. ##### image The image. ##### color The color intensities. ##### Compliance Adhere to this color standard: SVG, X11, or XPM. ##### name Return the color name or hex value. ##### exception Return any errors or warnings in this structure. ## QueryMagickColor QueryMagickColor() returns the red, green, blue, and opacity intensities for a given color name. The format of the QueryMagickColor method is:
      MagickBooleanType QueryMagickColor(const char *name,
        MagickPixelPacket *color,ExceptionInfo *exception)
A description of each parameter follows: ##### name The color name (e.g. white, blue, yellow). ##### color The red, green, blue, and opacity intensities values of the named color in this structure. ##### exception Return any errors or warnings in this structure. ## QueryMagickColorname QueryMagickColorname() returns a named color for the given color intensity. If an exact match is not found, a hex value is returned instead. For example an intensity of rgb:(0,0,0) returns black whereas rgb:(223,223,223) returns #dfdfdf. The format of the QueryMagickColorname method is:
      MagickBooleanType QueryMagickColorname(const Image *image,
        const PixelPacket *color,const ComplianceType compliance,
        const MagickBooleanType hex,char *name,ExceptionInfo *exception)
A description of each parameter follows. ##### image The image. ##### color The color intensities. ##### Compliance Adhere to this color standard: SVG, X11, or XPM. ##### hex A value other than zero returns the tuple in a hexidecimal format. ##### name Return the color name or hex value. ##### exception Return any errors or warnings in this structure. ## UniqueImageColors UniqueImageColors() returns the unique colors of an image. The format of the UniqueImageColors method is:
      Image *UniqueImageColors(const Image *image,ExceptionInfo *exception)
A description of each parameter follows. ##### image The image. ##### exception Return any errors or warnings in this structure. |

Discourse Server • Mailing Lists • ImageMagick Studio