# MagickCore, C API: Dealing with Image Colorspaces @ ImageMagick
ImageMagick® is a software suite to create, edit, compose, or convert bitmap images. It can read and write images in a variety of formats (over 200) including PNG, JPEG, JPEG-2000, GIF, WebP, Postscript, PDF, and SVG. Use ImageMagick to resize, flip, mirror, rotate, distort, shear and transform images, adjust image colors, apply various special effects, or draw text, lines, polygons, ellipses and Bézier curves.
Author: ImageMagick Studio LLC
Keywords: magickcore, c, api:, dealing, with, image, colorspaces, ImageMagick, PerlMagick, image processing, image, photo, software, Magick++, OpenMP, convert

GetImageColorspaceType • SetImageColorspace • SetImageGray • SetImageMonochrome • TransformImageColorspace

## GetImageColorspaceType

GetImageColorspaceType() returns the potential type of image: sRGBColorspaceType, RGBColorspaceType, GRAYColorspaceType, etc.

To ensure the image type matches its potential, use SetImageColorspaceType():

        (void) SetImageColorspaceType(image,GetImageColorspaceType(image),
    exception);

The format of the GetImageColorspaceType method is:

    ColorspaceType GetImageColorspaceType(const Image *image,
      ExceptionInfo *exception)

A description of each parameter follows:

image
  the image.
exception
  return any errors or warnings in this structure.

## SetImageColorspace

SetImageColorspace() sets the colorspace member of the Image structure.

The format of the SetImageColorspace method is:

    MagickBooleanType SetImageColorspace(Image *image,
      const ColorspaceType colorspace,ExceptiionInfo *exception)

A description of each parameter follows:

image
  the image.
colorspace
  the colorspace.
exception
  return any errors or warnings in this structure.

## SetImageGray

SetImageGray() returns MagickTrue if all the pixels in the image have the same red, green, and blue intensities and changes the type of the image to bi-level or grayscale.

The format of the SetImageGray method is:

    MagickBooleanType SetImageGray(const Image *image,
      ExceptionInfo *exception)

A description of each parameter follows:

image
  the image.
exception
  return any errors or warnings in this structure.

## SetImageMonochrome

SetImageMonochrome() 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 and changes the type of the image to bi-level.

The format of the SetImageMonochrome method is:

    MagickBooleanType SetImageMonochrome(Image *image,
      ExceptionInfo *exception)

A description of each parameter follows:

image
  the image.
exception
  return any errors or warnings in this structure.

## TransformImageColorspace

TransformImageColorspace() transforms an image colorspace, changing the image data to reflect the new colorspace.

The format of the TransformImageColorspace method is:

    MagickBooleanType TransformImageColorspace(Image *image,
      const ColorspaceType colorspace,ExceptionInfo *exception)

A description of each parameter follows:

image
  the image.
colorspace
  the colorspace.
exception
  return any errors or warnings in this structure.