<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: 27.0.0 -",
    "macOS: 27.0.0 -",
    "visionOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "ImagePlayground",
  "identifier" : "/documentation/ImagePlayground/ImagePlaygroundOptions/SizeSpecification-swift.struct/closest(to:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Image Playground"
    ],
    "preciseIdentifier" : "s:15ImagePlayground0aB7OptionsV17SizeSpecificationV7closest2toAESo6CGSizeV_tFZ"
  },
  "title" : "closest(to:)"
}
-->

# closest(to:)

Creates a new instance of this structure with a size value that best matches
the specified size.

```
static func closest(to size: CGSize) -> ImagePlaygroundOptions.SizeSpecification
```

## Parameters

`size`

The image size you want.

## Return Value

A structure with a supported size that most closely matches the
requested value in `size`.

## Discussion

This method finds the supported image size that’s closest to the value in the
`size` parameter. The method considers both the resolution and aspect ratio
of the requested size when choosing the output size.

---

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)