<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSImageRep",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSImageRep"
  },
  "title" : "NSImageRep"
}
-->

# NSImageRep

A semiabstract superclass that provides subclasses that you use to draw an image from a particular type of source data.

```
class NSImageRep
```

## Overview

The [`NSImageRep`](/documentation/AppKit/NSImageRep) class is called “semiabstract” because it has some instance variables and implementation of its own, in addition to defining subclasses. Although an [`NSImageRep`](/documentation/AppKit/NSImageRep) subclass can be used directly, it is typically accessed through an [`NSImage`](/documentation/AppKit/NSImage) object, which manages a group of image representations, choosing the best one for the current output device.

## Topics

### Creating Representations of Images

[`+  imageRepsWithContentsOfFile:`](/documentation/AppKit/NSImageRep/imageReps(withContentsOfFile:))

Creates and returns an array of image representation objects initialized using the contents of the specified file.

[`+  imageRepsWithPasteboard:`](/documentation/AppKit/NSImageRep/imageReps(with:))

Creates and returns an array of image representation objects initialized using the contents of the pasteboard.

[`+  imageRepsWithContentsOfURL:`](/documentation/AppKit/NSImageRep/imageReps(withContentsOf:))

Creates and returns an array of image representation objects initialized using the contents of the specified URL.

[`+  imageRepWithContentsOfFile:`](/documentation/AppKit/NSImageRep/init(contentsOfFile:))

Creates and returns an image representation object using the contents of the specified file.

[`+  imageRepWithPasteboard:`](/documentation/AppKit/NSImageRep/init(pasteboard:))

Creates and returns an image representation object using the contents of the specified pasteboard.

[`+  imageRepWithContentsOfURL:`](/documentation/AppKit/NSImageRep/init(contentsOf:))

Creates and returns an image representation object using the data at the specified URL.

[`-  init`](/documentation/AppKit/NSImageRep/init())

Creates and returns an image representation object.

[`-  initWithCoder:`](/documentation/AppKit/NSImageRep/init(coder:))

Creates and returns an image representation object from data in an unarchiver.

### Determining Types for Images

[`+  canInitWithData:`](/documentation/AppKit/NSImageRep/canInit(with:)-6zv56)

Returns a Boolean value that indicates whether the image representation can initialize itself from the specified data.

[`+  canInitWithPasteboard:`](/documentation/AppKit/NSImageRep/canInit(with:)-56pum)

Returns a Boolean value that indicates whether the receiver can initialize itself from the data on the specified pasteboard.

[`imageTypes`](/documentation/AppKit/NSImageRep/imageTypes)

Returns an array of UTI strings identifying the image types supported by the image representation, either directly or through a user-installed filter service.

[`imageUnfilteredTypes`](/documentation/AppKit/NSImageRep/imageUnfilteredTypes)

Returns an array of UTI strings identifying the image types supported directly by the ime representation.

[`+  imageFileTypes`](/documentation/AppKit/NSImageRep/imageFileTypes())

Returns the file types supported by the image representation class or one of its subclasses.

[`+  imagePasteboardTypes`](/documentation/AppKit/NSImageRep/imagePasteboardTypes())

Returns the pasteboard types supported by the image representation class or one of its subclasses.

[`+  imageUnfilteredFileTypes`](/documentation/AppKit/NSImageRep/imageUnfilteredFileTypes())

Returns the list of file types supported directly by the image representation.

[`+  imageUnfilteredPasteboardTypes`](/documentation/AppKit/NSImageRep/imageUnfilteredPasteboardTypes())

Returns the list of pasteboard types supported directly by the image representation.

### Accessing Size of Images

[`size`](/documentation/AppKit/NSImageRep/size)

The size of the image representation, measured in points in the user coordinate space.

### Specifying Information About the Representation

[`bitsPerSample`](/documentation/AppKit/NSImageRep/bitsPerSample)

The number of bits per sample in the object (if the object is a planar image, this property contains the number of bits per sample per plane).

[`colorSpaceName`](/documentation/AppKit/NSImageRep/colorSpaceName)

The name of the color space used by the image data.

[`alpha`](/documentation/AppKit/NSImageRep/hasAlpha)

A Boolean value that indicates whether the image data has an alpha channel.

[`opaque`](/documentation/AppKit/NSImageRep/isOpaque)

A Boolean value that indicates whether the image is opaque.

[`pixelsHigh`](/documentation/AppKit/NSImageRep/pixelsHigh)

The height of the image, measured in pixels.

[`pixelsWide`](/documentation/AppKit/NSImageRep/pixelsWide)

The width of the image, measured in pixels.

[`layoutDirection`](/documentation/AppKit/NSImageRep/layoutDirection)

The layout direction for the image.

[Device-Specific Value](/documentation/AppKit/device-specific-value)

A constant that is used by image representations to denote an attribute whose value changes to match the display device.

### Getting Core Graphics Images

[`-  CGImageForProposedRect:context:hints:`](/documentation/AppKit/NSImageRep/cgImage(forProposedRect:context:hints:))

Returns a Core Graphics image object that captures the drawing of the image.

### Drawing Images

[`-  draw`](/documentation/AppKit/NSImageRep/draw())

Implemented by subclasses to draw the image in the current coordinate system.

[`-  drawAtPoint:`](/documentation/AppKit/NSImageRep/draw(at:))

Draws the image representation’s image data at the specified point in the current coordinate system.

[`-  drawInRect:`](/documentation/AppKit/NSImageRep/draw(in:))

Draws the image, scaling it (as needed) to fit the specified rectangle.

[`-  drawInRect:fromRect:operation:fraction:respectFlipped:hints:`](/documentation/AppKit/NSImageRep/draw(in:from:operation:fraction:respectFlipped:hints:))

Draws all or part of the image in the specified rectangle in the current coordinate system.

[`HintKey`](/documentation/AppKit/NSImageRep/HintKey)

Constants for the keys to include in a hints dictionary when drawing the image.

### Managing Representation Subclasses of Images

[`+  imageRepClassForType:`](/documentation/AppKit/NSImageRep/class(forType:))

Returns the image representation subclass that handles image data for the specified UTI.

[`+  imageRepClassForData:`](/documentation/AppKit/NSImageRep/class(for:))

Returns the image representation subclass that handles the specified type of data.

[`registeredImageRepClasses`](/documentation/AppKit/NSImageRep/registeredClasses)

Returns an array containing the registered image representation classes.

[`+  registerImageRepClass:`](/documentation/AppKit/NSImageRep/registerClass(_:))

Adds the specified class to the registry of available image representation subclasses.

[`+  unregisterImageRepClass:`](/documentation/AppKit/NSImageRep/unregisterClass(_:))

Removes the specified image representation subclass from the registry of available image representations.

[`+  imageRepClassForFileType:`](/documentation/AppKit/NSImageRep/class(forFileType:))

Returns the image representation subclass that handles data with the specified type.

[`+  imageRepClassForPasteboardType:`](/documentation/AppKit/NSImageRep/class(forPasteboardType:))

Returns the image representation subclass that handles data with the specified pasteboard type.

### Notifications

[`NSImageRepRegistryDidChangeNotification`](/documentation/AppKit/NSImageRep/registryDidChangeNotification)

Posted whenever the image representation class registry changes.

[`NSImageRepRegistryChangedNotification`](/documentation/AppKit/NSImageRepRegistryChangedNotification)

Posted whenever the image representation class registry changes.

## Relationships

### Inherited By

[`NSEPSImageRep`](/documentation/AppKit/NSEPSImageRep)

[`NSCIImageRep`](/documentation/AppKit/NSCIImageRep)

[`NSPICTImageRep`](/documentation/AppKit/NSPICTImageRep)

[`NSBitmapImageRep`](/documentation/AppKit/NSBitmapImageRep)

[`NSCustomImageRep`](/documentation/AppKit/NSCustomImageRep)

[`NSPDFImageRep`](/documentation/AppKit/NSPDFImageRep)

### Conforms To

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

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

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

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

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

[`NSCopying`](/documentation/Foundation/NSCopying)

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

[`NSCoding`](/documentation/Foundation/NSCoding)

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

---

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)