<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 13.0.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CreateMLComponents",
  "identifier" : "/documentation/CreateMLComponents/ImageScaler",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Create ML Components"
    ],
    "preciseIdentifier" : "s:18CreateMLComponents11ImageScalerV"
  },
  "title" : "ImageScaler"
}
-->

# ImageScaler

An image scaling transformer.

```
struct ImageScaler
```

## Topics

### Creating a transformer

[`init(targetSize: CGSize)`](/documentation/CreateMLComponents/ImageScaler/init(targetSize:))

Creates an image scaler transformer. This transformer is used to scale an image to the `targetSize`.

[`init(targetHeight: Double)`](/documentation/CreateMLComponents/ImageScaler/init(targetHeight:))

Creates an image scaler transformer that preserves the aspect ratio.

[`init(targetWidth: Double)`](/documentation/CreateMLComponents/ImageScaler/init(targetWidth:))

Creates an image scaler transformer that preserves the aspect ratio.

### Getting the target image size

[`var targetSize: CGSize`](/documentation/CreateMLComponents/ImageScaler/targetSize)

The target image size.

### Performing the transformation

[`func applied(to: CIImage, eventHandler: EventHandler?) throws -> CIImage`](/documentation/CreateMLComponents/ImageScaler/applied(to:eventHandler:))

Perform the image scaler operation on the input pixelBuffer.

## Relationships

### Conforms To

[`Transformer`](/documentation/CreateMLComponents/Transformer)

[`Decodable`](/documentation/Swift/Decodable)

[`Escapable`](/documentation/Swift/Escapable)

[`Sendable`](/documentation/Swift/Sendable)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Copyable`](/documentation/Swift/Copyable)

[`Encodable`](/documentation/Swift/Encodable)

---

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)