Contents

writeJPEGRepresentation(of:to:colorSpace:options:)

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

Declaration

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

Parameters

  • image:

    The image object to render.

  • url:

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

  • colorSpace:

    The color space in which to render the output image. This color space must conform to either the Rgb or 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.

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