---
title: "init(contentsOfFile:)"
framework: uikit
role: symbol
role_heading: Initializer
path: "uikit/uiimage/init(contentsoffile:)"
---

# init(contentsOfFile:)

Initializes and returns the image object with the contents of the specified file.

## Declaration

```swift
init?(contentsOfFile path: String)
```

## Parameters

- `path`: The path to the file. This path should include the filename extension that identifies the type of the image data.

## Return Value

Return Value An initialized UIImage object, or nil if the method could not find the file or initialize the image from its contents.

## Discussion

Discussion This method loads the image data into memory and marks it as purgeable. If the data is purged and needs to be reloaded, the image object loads that data again from the specified path.

## See Also

### Creating and initializing image objects

- [init(data:)](uikit/uiimage/init(data:).md)
- [init(data:scale:)](uikit/uiimage/init(data:scale:).md)
- [init(cgImage:)](uikit/uiimage/init(cgimage:)-14qlb.md)
- [init(cgImage:scale:orientation:)](uikit/uiimage/init(cgimage:scale:orientation:)-2ouhh.md)
- [init(ciImage:)](uikit/uiimage/init(ciimage:)-93vu1.md)
- [init(ciImage:scale:orientation:)](uikit/uiimage/init(ciimage:scale:orientation:)-9gpyn.md)
- [UIImageReader](uikit/uiimagereader-swift.struct.md)
