---
title: "copyCGImage(at:actualTime:)"
framework: avfoundation
role: symbol
role_heading: Instance Method
path: "avfoundation/avassetimagegenerator/copycgimage(at:actualtime:)"
---

# copyCGImage(at:actualTime:)

Returns an image for the asset at or near a specified time.

## Declaration

```swift
func copyCGImage(at requestedTime: CMTime, actualTime: UnsafeMutablePointer<CMTime>?) throws -> CGImage
```

## Parameters

- `requestedTime`: A time within the asset timeline for which to create an image.
- `actualTime`: Upon return, contains the time at which the image was actually generated. If you’re not interested in this information, pass NULL.

## Return Value

Return Value A CGImage for the asset at or near a specified time, or NULL if the image could not be created.

## Discussion

Discussion This method returns the image synchronously.

## See Also

### Generating images

- [image(at:)](avfoundation/avassetimagegenerator/image(at:).md)
- [images(for:)](avfoundation/avassetimagegenerator/images(for:).md)
- [AVAssetImageGenerator.Images](avfoundation/avassetimagegenerator/images.md)
- [generateCGImageAsynchronously(for:completionHandler:)](avfoundation/avassetimagegenerator/generatecgimageasynchronously(for:completionhandler:).md)
- [generateCGImagesAsynchronously(forTimes:completionHandler:)](avfoundation/avassetimagegenerator/generatecgimagesasynchronously(fortimes:completionhandler:).md)
- [AVAssetImageGeneratorCompletionHandler](avfoundation/avassetimagegeneratorcompletionhandler.md)
- [cancelAllCGImageGeneration()](avfoundation/avassetimagegenerator/cancelallcgimagegeneration().md)
