<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSBitmapImageRep/getCompression(_:factor:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSBitmapImageRep(im)getCompression:factor:"
  },
  "title" : "getCompression(_:factor:)"
}
-->

# getCompression(_:factor:)

Returns by indirection the bitmap image representation’s compression type and compression factor.

```
func getCompression(_ compression: UnsafeMutablePointer<NSBitmapImageRep.TIFFCompression>?, factor: UnsafeMutablePointer<Float>?)
```

## Parameters

`compression`

On return, an `enum` constant that represents the compression type used on the data; it corresponds to one of the values returned by the class method [`getTIFFCompressionTypes(_:count:)`](/documentation/AppKit/NSBitmapImageRep/getTIFFCompressionTypes(_:count:)).

`factor`

A float value that is specific to the compression type. Many types of compression don’t support varying degrees of compression and thus ignore `factor`. JPEG compression allows a compression factor ranging from 0.0 to 1.0, with 0.0 being the lowest and 1.0 being the highest.

## Discussion

Use this method to get information on the compression type for the source image data.

---

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)