---
title: MLImageConstraint
framework: coreml
role: symbol
role_heading: Class
path: coreml/mlimageconstraint
---

# MLImageConstraint

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

## Declaration

```swift
class MLImageConstraint
```

## Overview

Overview In CoreML, an image is a collection of pixels represented by CVPixelBuffer (Swift) or CVPixelBuffer (Objective-C). An image feature is a model input or output that accepts or produces, respectively, an image bundled in an 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. The feature description for an image input or output has: Its type property set to MLFeatureType.image Its imageConstraint property set to an 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 property.

## Topics

### Accessing the constraints

- [pixelsWide](coreml/mlimageconstraint/pixelswide.md)
- [pixelsHigh](coreml/mlimageconstraint/pixelshigh.md)
- [pixelFormatType](coreml/mlimageconstraint/pixelformattype.md)

### Inspecting acceptable sizes

- [sizeConstraint](coreml/mlimageconstraint/sizeconstraint.md)
- [MLImageSizeConstraint](coreml/mlimagesizeconstraint.md)

### Initializers

- [init(coder:)](coreml/mlimageconstraint/init(coder:).md)

## Relationships

### Inherits From

- [NSObject](objectivec/nsobject-swift.class.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSCoding](foundation/nscoding.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [NSSecureCoding](foundation/nssecurecoding.md)

## See Also

### Creating image feature values

- [init(pixelBuffer:)](coreml/mlfeaturevalue/init(pixelbuffer:).md)
- [init(CGImage:pixelsWide:pixelsHigh:pixelFormatType:options:)](coreml/mlfeaturevalue/init(cgimage:pixelswide:pixelshigh:pixelformattype:options:)-2zg43.md)
- [init(CGImage:orientation:pixelsWide:pixelsHigh:pixelFormatType:options:)](coreml/mlfeaturevalue/init(cgimage:orientation:pixelswide:pixelshigh:pixelformattype:options:)-4nme0.md)
- [init(CGImage:constraint:options:)](coreml/mlfeaturevalue/init(cgimage:constraint:options:)-1j00l.md)
- [init(CGImage:orientation:constraint:options:)](coreml/mlfeaturevalue/init(cgimage:orientation:constraint:options:)-87vk0.md)
- [init(imageAtURL:pixelsWide:pixelsHigh:pixelFormatType:options:)](coreml/mlfeaturevalue/init(imageaturl:pixelswide:pixelshigh:pixelformattype:options:).md)
- [init(imageAtURL:orientation:pixelsWide:pixelsHigh:pixelFormatType:options:)](coreml/mlfeaturevalue/init(imageaturl:orientation:pixelswide:pixelshigh:pixelformattype:options:).md)
- [init(imageAtURL:constraint:options:)](coreml/mlfeaturevalue/init(imageaturl:constraint:options:).md)
- [init(imageAtURL:orientation:constraint:options:)](coreml/mlfeaturevalue/init(imageaturl:orientation:constraint:options:).md)
- [MLFeatureValue.ImageOption](coreml/mlfeaturevalue/imageoption.md)
