Instance Method

writePNGRepresentation(of:to:format:colorSpace:options:)

Renders the image and exports the resulting image data as a file in PNG format.

Declaration

func writePNGRepresentation(of image: CIImage, to url: URL, format: CIFormat, colorSpace: CGColorSpace, options: [CIImageRepresentationOption : Any] = [:]) throws

Parameters

image

The image object to render.

url

The file URL at which to write the output PNG file.

format

The pixel format for the output image.

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.

Return Value

If true, file export succeeded. If false, examine the errorPtr parameter for possible failure reasons.

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.