<!--
{
  "availability" : [
    "Swift: 6.3.0 -",
    "Xcode: 26.4.0 -",
    "iOS: 14.0.0 -",
    "iPadOS: 14.0.0 -",
    "macCatalyst: 14.0.0 -",
    "macOS: 11.0.0 -",
    "swift: 6.0.0 -",
    "tvOS: 14.0.0 -",
    "visionOS: -",
    "watchOS: 7.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Testing",
  "identifier" : "/documentation/Testing/AttachableImageFormat/init(contentType:encodingQuality:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Swift Testing",
      "CoreGraphics",
      "Testing"
    ],
    "preciseIdentifier" : "s:7Testing21AttachableImageFormatV01_A13_CoreGraphicsE11contentType15encodingQualityAC07UniformH11Identifiers6UTTypeV_Sftcfc"
  },
  "title" : "init(contentType:encodingQuality:)"
}
-->

# init(contentType:encodingQuality:)

Initialize an instance of this type with the given content type and
encoding quality.

```
init(contentType: UTType, encodingQuality: Float = 1.0)
```

## Parameters

`contentType`

The image format to use when encoding images.

`encodingQuality`

The encoding quality to use when encoding images. For
the lowest supported quality, pass `0.0`. For the highest supported
quality, pass `1.0`.

## Discussion

If the target image format does not support variable-quality encoding,
the value of the `encodingQuality` argument is ignored.

If `contentType` does not conform to [`UTType.image`](https://developer.apple.com/documentation/uniformtypeidentifiers/uttype-swift.struct/image),
the result is undefined.

---

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)