Instance Method

jpegRepresentation(of:colorSpace:options:)

Renders the image and exports the resulting image data in JPEG format.

Declaration

func jpegRepresentation(of image: CIImage, colorSpace: CGColorSpace, options: [CIImageRepresentationOption : Any] = [:]) -> Data?

Parameters

image

The image object to render.

colorSpace

The color space in which to render the output image. This color space must conform to either the CGColorSpaceModel.rgb or CGColorSpaceModel.monochrome model and must be compatible with the specified pixel format.

options

A dictionary with additional options for export. Use the kCGImageDestinationLossyCompressionQuality key to specify JPEG compression level. Other supported keys include avDepthData, depthImage, and disparityImage.

Return Value

A data representation of the rendered image in JPEG format, or nil if the image could not be rendered.

Discussion

To render an image for export, the image’s contents must not be empty and its extent dimensions must be finite. To export after applying a filter whose output has infinite extent, see the clampedToExtent() method.

See Also

Rendering Images for Data or File Export

static let avDepthData: CIImageRepresentationOption

options dictionary key for image export methods to represent data as AVDepthData.

static let depthImage: CIImageRepresentationOption

options dictionary key for image export methods to output depth data.

static let disparityImage: CIImageRepresentationOption

options dictionary key for image export methods to output disparity data.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software