---
title: "image(from:scale:)"
framework: pencilkit
role: symbol
role_heading: Instance Method
path: "pencilkit/pkdrawing-swift.struct/image(from:scale:)-6p3zc"
---

# image(from:scale:)

Returns an image object that contains the specified portion of the drawing.

## Declaration

```swift
func image(from rect: CGRect, scale: CGFloat) -> NSImage
```

## Parameters

- `rect`: The portion of the drawing that you want to capture. Specify a rectangle in the canvas’ coordinate system.
- `scale`: The scale factor at which to create the image. Specifying scale factors greater than 1.0 creates an image with more detail. For example, you might specify a scale factor of 2.0 or 3.0 when displaying the image on a Retina display.

## Return Value

Return Value A new image object that contains the rendered content.

## Discussion

Discussion This method creates a new image and renders content from the canvas into that image at the specified scale factor.

## See Also

### Generating an image

- [image(from:scale:)](pencilkit/pkdrawing-swift.struct/image(from:scale:)-220d0.md)
