<!--
{
  "availability" : [
    "macOS: 10.6.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSImage/init(cgImage:size:)-8oznv",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSImage(im)initWithCGImage:size:"
  },
  "title" : "init(cgImage:size:)"
}
-->

# init(cgImage:size:)

Creates a new image using the contents of the provided image.

```
convenience init(cgImage: CGImage, size: NSSize)
```

## Parameters

`cgImage`

The source image.

`size`

The size of the new image. Use <doc://com.apple.documentation/documentation/CoreFoundation/CGSize/zero>, or <doc://com.apple.documentation/documentation/Foundation/NSZeroSize> in Objective-C, to have the new image adopt the pixel dimensions of the source image.

## Discussion

Don’t assume anything about the image, other than drawing it is equivalent to drawing the source image.

This is not a designated initializer.

---

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)