---
title: "pngRepresentation(of:format:colorSpace:options:)"
framework: coreimage
role: symbol
role_heading: Instance Method
path: "coreimage/cicontext/pngrepresentation(of:format:colorspace:options:)"
---

# pngRepresentation(of:format:colorSpace:options:)

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

## Declaration

```swift
func pngRepresentation(of image: CIImage, format: CIFormat, colorSpace: CGColorSpace, options: [CIImageRepresentationOption : Any] = [:]) -> Data?
```

## Parameters

- `image`: The image object to render.
- `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 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`: No options keys are supported at this time.

## Return Value

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

## Discussion

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

- [tiffRepresentation(of:format:colorSpace:options:)](coreimage/cicontext/tiffrepresentation(of:format:colorspace:options:).md)
- [jpegRepresentation(of:colorSpace:options:)](coreimage/cicontext/jpegrepresentation(of:colorspace:options:).md)
- [heifRepresentation(of:format:colorSpace:options:)](coreimage/cicontext/heifrepresentation(of:format:colorspace:options:).md)
- [heif10Representation(of:colorSpace:options:)](coreimage/cicontext/heif10representation(of:colorspace:options:).md)
- [openEXRRepresentation(of:options:)](coreimage/cicontext/openexrrepresentation(of:options:).md)
- [writeTIFFRepresentation(of:to:format:colorSpace:options:)](coreimage/cicontext/writetiffrepresentation(of:to:format:colorspace:options:).md)
- [writeJPEGRepresentation(of:to:colorSpace:options:)](coreimage/cicontext/writejpegrepresentation(of:to:colorspace:options:).md)
- [writePNGRepresentation(of:to:format:colorSpace:options:)](coreimage/cicontext/writepngrepresentation(of:to:format:colorspace:options:).md)
- [writeHEIFRepresentation(of:to:format:colorSpace:options:)](coreimage/cicontext/writeheifrepresentation(of:to:format:colorspace:options:).md)
- [writeHEIF10Representation(of:to:colorSpace:options:)](coreimage/cicontext/writeheif10representation(of:to:colorspace:options:).md)
- [writeOpenEXRRepresentation(of:to:options:)](coreimage/cicontext/writeopenexrrepresentation(of:to:options:).md)
- [CIImageRepresentationOption](coreimage/ciimagerepresentationoption.md)
