<!--
{
  "availability" : [
    "iOS: 10.0.0 -",
    "iPadOS: 10.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: 10.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIGraphicsImageRenderer/jpegData(withCompressionQuality:actions:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UIGraphicsImageRenderer(im)JPEGDataWithCompressionQuality:actions:"
  },
  "title" : "jpegData(withCompressionQuality:actions:)"
}
-->

# jpegData(withCompressionQuality:actions:)

Creates a JPEG-encoded image from a set of drawing instructions.

```
func jpegData(withCompressionQuality compressionQuality: CGFloat, actions: (UIGraphicsImageRendererContext) -> Void) -> Data
```

## Parameters

`compressionQuality`

A <doc://com.apple.documentation/documentation/CoreFoundation/CGFloat-swift.struct> value between `0.0` and `1.0`, representing the compression level the JPEG encoder should use. A value of `1.0` specifies lossless compression, and a value of `0.0` specifies maximum compression.

`actions`

A [`UIGraphicsImageRenderer.DrawingActions`](/documentation/UIKit/UIGraphicsImageRenderer/DrawingActions) block that, when invoked by the renderer, executes a set of drawing instructions to create the output image.

## Return Value

A <doc://com.apple.documentation/documentation/Foundation/Data> object representing a JPEG-encoded representation of the image created by the supplied drawing actions.

## Discussion

You provide a set of drawing instructions as the block argument to this method, and the method returns the resulting image as a JPEG-encoded <doc://com.apple.documentation/documentation/Foundation/Data> object.

The JPEG format does not support transparency, so this method is only appropriate for use with opaque images.

You can call this method repeatedly to create multiple images, each of which has identical dimensions and format.

---

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)