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

# MLImageConstraint

The width, height, and pixel format constraints of an image feature.

```
class MLImageConstraint
```

## Overview

In CoreML, an *image* is a collection of pixels represented by <doc://com.apple.documentation/documentation/CoreVideo/cvpixelbuffer-q2e> (Swift) or <doc://com.apple.documentation/documentation/CoreVideo/CVPixelBuffer> (Objective-C). An *image feature* is a model input or output that accepts or produces, respectively, an image bundled in an [`MLFeatureValue`](/documentation/CoreML/MLFeatureValue). `MLImageConstraint` defines the image feature’s limitations for the images within an `MLFeatureValue`.

If a model has an image feature for an input or output, the model author uses an *image feature description* by creating an [`MLFeatureDescription`](/documentation/CoreML/MLFeatureDescription). The feature description for an image input or output has:

- Its [`type`](/documentation/CoreML/MLFeatureDescription/type) property set to [`MLFeatureType.image`](/documentation/CoreML/MLFeatureType/image)
- Its [`imageConstraint`](/documentation/CoreML/MLFeatureDescription/imageConstraint) property set to an [`MLImageConstraint`](/documentation/CoreML/MLImageConstraint) instance configured to the image feature’s size and format

Image features that support additional image sizes provide a range of sizes, or a list of discrete sizes, in their image constraint’s [`sizeConstraint`](/documentation/CoreML/MLImageConstraint/sizeConstraint) property.

## Topics

### Accessing the constraints

[`pixelsWide`](/documentation/CoreML/MLImageConstraint/pixelsWide)

The model’s default width for an image feature.

[`pixelsHigh`](/documentation/CoreML/MLImageConstraint/pixelsHigh)

The model’s default height for an image feature.

[`pixelFormatType`](/documentation/CoreML/MLImageConstraint/pixelFormatType)

The model’s pixel format for an image feature.

### Inspecting acceptable sizes

[`sizeConstraint`](/documentation/CoreML/MLImageConstraint/sizeConstraint)

Additional sizes this image feature supports.

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

A list or range of sizes that augment an image constraint’s default 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)