# ImageCollection Class

> An image collection can hold multiple images, created from an image file.

- Product: Adobe PDF Library 21
- Language: .NET Framework
- Version: APDFL21.0.0PlusP1e
- HTML page: https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/ImageCollection
- Version index: https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/llms.txt

```csharp
class ImageCollection : SystemIDisposable
```

**Namespace:** `Datalogics::PDFL`

**Inherits from:** `SystemIDisposable`

## Description

An image collection can hold multiple images, created from an image file.

The full set of images in the collection can be saved to a single image file, but only as a .tif image file. For any other file type (JPG, PNG, and so on), the collection can only be saved as one image object per file.

**Referenced by:** [`Page`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/Page.md)

**Uses types:** [`Document`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/Document.md), [`Image`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/Image.md), [`ImageSaveParams`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/ImageSaveParams.md), [`ImageType`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/enum/ImageType.md)

## Constructors

### ImageCollection

```csharp
Datalogics.PDFL.ImageCollection.ImageCollection()
```

*constructor*

Create an empty image collection, which can have Image objects added to it.

### ImageCollection

```csharp
Datalogics.PDFL.ImageCollection.ImageCollection(Image image)
```

*constructor*

**Parameters**

- `image` ([`Image`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/Image.md)): the Image object to be inserted upon creation.

Create a new image collection containing the supplied Image object.

### ImageCollection

```csharp
Datalogics.PDFL.ImageCollection.ImageCollection(string fileName)
```

*constructor*

**Parameters**

- `fileName` (`string`): The physical image file from which an image collection will be created.

Create from an image file. If the file is a TIFF, then an Image object will be created for each "page" of the TIFF. For all other types, only 1 Image object will be created.

### ImageCollection

```csharp
Datalogics.PDFL.ImageCollection.ImageCollection(string fileName, Document document)
```

*constructor*

**Parameters**

- `fileName` (`string`): The physical image file from which an image collection will be created.
- `document` ([`Document`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/Document.md)): the document in which the image is intended to be used.

Create from an image file. If the file is a TIFF, then an Image object will be created for each "page" of the TIFF.

For all other types, only 1 Image object will be created.

Specifying the document optimizes data usage for this image within that document.

### ImageCollection

```csharp
Datalogics.PDFL.ImageCollection.ImageCollection(System.IO.Stream stream)
```

*constructor*

**Parameters**

- `stream` (`System.IO.Stream`): The Stream from which to read the ImageCollection.

Create an ImageCollection from a Stream.

This allows an ImageCollection to be read from a Stream object. The Stream must be seekable. Suitable examples are FileStream and MemoryStream. The Stream must contain image data in the TIFF Format.

### ImageCollection

```csharp
Datalogics.PDFL.ImageCollection.ImageCollection(System.IO.Stream stream, Document document)
```

*constructor*

**Parameters**

- `stream` (`System.IO.Stream`): The Stream from which to read the ImageCollection.
- `document` ([`Document`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/Document.md)): The Document in which the ImageCollection is intended to be used.

Create an ImageCollection from a Stream.

This allows an ImageCollection to be read from a Stream object. The Stream must be seekable. Suitable examples are FileStream and MemoryStream. The Stream must contain image data in the TIFF format.

## Properties

### Count

```csharp
int Datalogics.PDFL.ImageCollection.Count { get; }
```

Gets the number of Image objects in this collection.

## Methods

### Append

```csharp
void Datalogics.PDFL.ImageCollection.Append(Image image)
```

**Parameters**

- `image` ([`Image`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/Image.md)): the Image object to be inserted.

**Returns:** `void`

Insert the given Image object at the end of the ImageCollection.

### Dispose

```csharp
void Datalogics.PDFL.ImageCollection.Dispose()
```

**Returns:** `void`

### GetImage

```csharp
Image Datalogics.PDFL.ImageCollection.GetImage(int index)
```

**Parameters**

- `index` (`int`): the index of the Image to be retrieved.

**Returns:** [`Image`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/Image.md)

the Image object at the specified index.

Retrieve the Image object at the specified index. Note that an exception will be generated if an index is given which is out of range.

### Save

```csharp
void Datalogics.PDFL.ImageCollection.Save(string filename, ImageType type)
```

**Parameters**

- `filename` (`string`): the file which to save the image.
- `type` ([`ImageType`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/enum/ImageType.md)): the image type to which to be saved. NOTE: The resolution of the first Image in the collection is used as the target Resolution for saving. (Support for saving multiple, different resolutions isn't available)

**Returns:** `void`

Save the images in the collection to the specified file and image type. Multiple images can only be save to an image type of TIFF, otherwise an exception will be thrown.

### Save

```csharp
void Datalogics.PDFL.ImageCollection.Save(string filename, ImageType type, ImageSaveParams saveparams)
```

**Parameters**

- `filename` (`string`): the file which to save the image.
- `type` ([`ImageType`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/enum/ImageType.md)): the image type to which to be saved.
- `saveparams` ([`ImageSaveParams`](https://docs.datalogics.com/apdfl21/DotNetFramework/APDFL21.0.0PlusP1e/class/ImageSaveParams.md)): the ImageSaveParams parameters for customizing the image saving. NOTE: The resolution of the first Image in the collection is used as the target Resolution for saving. (Support for saving multiple, different resolutions isn't available)

**Returns:** `void`

Save the images in the collection to the specified file and image type. Multiple images can only be save to an image type of TIFF, otherwise an exception will be thrown.
