<!--
{
  "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(pathExtension:encodingQuality:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Swift Testing",
      "CoreGraphics",
      "Testing"
    ],
    "preciseIdentifier" : "s:7Testing21AttachableImageFormatV01_A13_CoreGraphicsE13pathExtension15encodingQualityACSgSS_Sftcfc"
  },
  "title" : "init(pathExtension:encodingQuality:)"
}
-->

# init(pathExtension:encodingQuality:)

Construct an instance of this type with the given path extension and
encoding quality.

```
init?(pathExtension: String, encodingQuality: Float = 1.0)
```

## Parameters

`pathExtension`

A path extension corresponding to 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 `pathExtension` does not correspond to a recognized image format, this
initializer returns `nil`:

- On Apple platforms, the content type corresponding to `pathExtension`
  must conform to [`UTType.image`](https://developer.apple.com/documentation/uniformtypeidentifiers/uttype-swift.struct/image).
- On Windows, there must be a corresponding subclass of [`IWICBitmapEncoder`](https://learn.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicbitmapencoder)
  registered with Windows Imaging Component.

---

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)