---
title: AttachableAsImage
framework: testing
role: symbol
role_heading: Protocol
path: testing/attachableasimage
---

# AttachableAsImage

A protocol describing images that can be converted to instances of Attachment.

## Declaration

```swift
protocol AttachableAsImage
```

## Overview

Overview Instances of types conforming to this protocol do not themselves conform to Attachable. Instead, the testing library provides additional initializers on Attachment that take instances of such types and handle converting them to image data when needed. You do not generally need to add your own conformances to this protocol. For a list of types that automatically conform to this protocol, see Attach images.

## Topics

### Instance Methods

- [withUnsafeBytes(as:_:)](testing/attachableasimage/withunsafebytes(as:_:).md)

## See Also

### Attaching images to tests

- [AttachableImageFormat](testing/attachableimageformat.md)
- [init(_:named:as:sourceLocation:)](testing/attachment/init(_:named:as:sourcelocation:).md)
- [record(_:named:as:sourceLocation:)](testing/attachment/record(_:named:as:sourcelocation:).md)
