<!--
{
  "availability" : [
    "iOS: 12.0.0 -",
    "iPadOS: 12.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.14.0 -",
    "tvOS: 12.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 5.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreML",
  "identifier" : "/documentation/CoreML/MLImageSizeConstraint",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Core ML"
    ],
    "preciseIdentifier" : "c:objc(cs)MLImageSizeConstraint"
  },
  "title" : "MLImageSizeConstraint"
}
-->

# MLImageSizeConstraint

A list or range of sizes that augment an image constraint’s default size.

```
class MLImageSizeConstraint
```

## Overview

You use an `MLImageSizeConstraint` to express what image sizes of an image feature a model will accept as input or produce as output.

Use [`type`](/documentation/CoreML/MLImageSizeConstraint/type) to determine which properties describe what image sizes the model’s image feature expects as input or produces as output.

If `type` is:

- [`MLImageSizeConstraintType.range`](/documentation/CoreML/MLImageSizeConstraintType/range), the image feature accepts any image that has a width in [`pixelsWideRange`](/documentation/CoreML/MLImageSizeConstraint/pixelsWideRange) and a height in [`pixelsHighRange`](/documentation/CoreML/MLImageSizeConstraint/pixelsHighRange).
- [`MLImageSizeConstraintType.enumerated`](/documentation/CoreML/MLImageSizeConstraintType/enumerated), the image feature accepts any image size listed in [`enumeratedImageSizes`](/documentation/CoreML/MLImageSizeConstraint/enumeratedImageSizes).
- [`MLImageSizeConstraintType.unspecified`](/documentation/CoreML/MLImageSizeConstraintType/unspecified), the `MLImageSizeConstraint` instance is not configured and should be ignored. Instead, use the image feature’s default image size constraint, defined by [`pixelsWide`](/documentation/CoreML/MLImageConstraint/pixelsWide) and [`pixelsHigh`](/documentation/CoreML/MLImageConstraint/pixelsHigh).

![Graph diagram showing the constraint’s rectangle defined by the width and height ranges of the constraint, and a blue rectangle, representing a valid image size. The diagram’s X-axis spans from 0 to 250 pixels and the Y-axis spans from 0 to 200 pixels. The constraint rectangle, which has a dashed outline, has a width that spans from 50 to 250 pixels, and a height that spans from 100 to 200 pixels. The sample image size has its lower-left corner at the graph’s origin and its upper-right corner is within the bounds of the constraint rectangle, at 150 pixels wide by 180 pixels high.](images/com.apple.coreml/media-3027121@2x.png)

## Topics

### Determining relevant constraints

[`type`](/documentation/CoreML/MLImageSizeConstraint/type)

Indicator of which properties to inspect for this image size constraint.

[`MLImageSizeConstraintType`](/documentation/CoreML/MLImageSizeConstraintType)

The modes that determine how the model defines a feature’s image size constraint.

### Accessing the image size ranges

[`pixelsWideRange`](/documentation/CoreML/MLImageSizeConstraint/pixelsWideRange)

The range of widths a model’s image feature accepts as input or produces as output.

[`pixelsHighRange`](/documentation/CoreML/MLImageSizeConstraint/pixelsHighRange)

The range of heights a model’s image feature accepts as input or produces as output.

### Accessing the enumerated image sizes

[`enumeratedImageSizes`](/documentation/CoreML/MLImageSizeConstraint/enumeratedImageSizes)

An array of image sizes a model’s image feature accepts as input or produces as output.

[`MLImageSize`](/documentation/CoreML/MLImageSize)

The width and height of an image feature 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)