<!--
{
  "availability" : [
    "iOS: 10.0.0 -",
    "iPadOS: 10.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.12.0 -",
    "tvOS: 10.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreImage",
  "identifier" : "/documentation/CoreImage/CIContext/jpegRepresentation(of:colorSpace:options:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Core Image",
      "CoreImage"
    ],
    "preciseIdentifier" : "c:objc(cs)CIContext(im)JPEGRepresentationOfImage:colorSpace:options:"
  },
  "title" : "jpegRepresentation(of:colorSpace:options:)"
}
-->

# jpegRepresentation(of:colorSpace:options:)

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

```
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 <doc://com.apple.documentation/documentation/CoreGraphics/CGColorSpaceModel/rgb> or <doc://com.apple.documentation/documentation/CoreGraphics/CGColorSpaceModel/monochrome> model and must be compatible with the specified pixel format.

`options`

A dictionary with additional options for export. Use the <doc://com.apple.documentation/documentation/ImageIO/kCGImageDestinationLossyCompressionQuality> key to specify JPEG compression level.  Other supported keys include [`avDepthData`](/documentation/CoreImage/CIImageRepresentationOption/avDepthData), [`depthImage`](/documentation/CoreImage/CIImageRepresentationOption/depthImage), and [`disparityImage`](/documentation/CoreImage/CIImageRepresentationOption/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`](/documentation/CoreImage/CIImage/extent) dimensions must be finite. To export after applying a filter whose output has infinite extent, see the [`clampedToExtent()`](/documentation/CoreImage/CIImage/clampedToExtent()) method.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)