<!--
{
  "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" : "ImageIO",
  "identifier" : "/documentation/ImageIO/CGImageSourceGetPrimaryImageIndex(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Image I/O"
    ],
    "preciseIdentifier" : "c:@F@CGImageSourceGetPrimaryImageIndex"
  },
  "title" : "CGImageSourceGetPrimaryImageIndex(_:)"
}
-->

# CGImageSourceGetPrimaryImageIndex(_:)

Returns the index of the primary image for an High Efficiency Image File Format (HEIF) image.

```
func CGImageSourceGetPrimaryImageIndex(_ isrc: CGImageSource) -> Int
```

## Parameters

`isrc`

The image source that contains the image data.

## Return Value

The index of the primary image, or `0` for image formats other than the HEIF format.

---

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)