---
Product: Aspose.PDF
Platform: net
Page Type: reference
Canonical URL: https://reference.aspose.org/pdf/net/XImageCollection
---

# XImageCollection

## Overview

`XImageCollection` is a class in Aspose.PDF FOSS for .NET.
Inherits from: `ImageCollection`.

Collection of image XObjects on a page, with XImage-typed accessors and editing helpers.

This class provides 21 methods for working with XImageCollection objects in .NET programs.
Available methods include: `Add`, `Clear`, `Contains`, `CopyTo`, `Delete`, `GetByName`, `GetEnumerator`, `GetImageName`, `Remove`, `Replace`.
All public members are accessible to any .NET application after installing the Aspose.PDF FOSS for .NET package.
Properties: `Count`, `IsReadOnly`, `IsSynchronized`, `Names`, `SyncRoot`.

## Properties

| Name | Type | Access | Description |
|------|------|--------|-------------|
| `Count` | `int` | Read | Number of images in the collection. |
| `IsReadOnly` | `bool` | Read | Whether the collection is read-only. |
| `IsSynchronized` | `bool` | Read | Whether the collection is thread-safe. |
| `SyncRoot` | `object` | Read | Synchronization root for IsSynchronized; returns this collection. |
| `Names` | `string[]` | Read | The resource names of every image in the collection. |

## Methods

| Signature | Description |
|-----------|-------------|
| `Add(image: XImage)` | Append an existing XImage to the collection and return its assigned resource name. |
| `Add(image: Stream)` | Append an image from a stream; returns its assigned resource name. |
| `Add(image: Stream, filterType: ImageFilterType)` | Append an image from a stream using the given filter; returns its assigned resource name. |
| `Add(image: Stream, quality: int)` | Append an image from a stream re-encoded as JPEG at the given quality. |
| `Add(bitmapInfo: BitmapInfo)` | Append an image from a raw bitmap; returns its assigned resource name. |
| `Add(bitmapInfo: BitmapInfo, filterType: ImageFilterType)` | Append an image from a raw bitmap using the given filter; returns its assigned resource name. |
| `Clear()` | Remove every image from the collection. |
| `Contains(item: XImage)` | Whether the collection contains the supplied image. |
| `CopyTo(array: XImage[], index: int)` | Copy collection contents into an array starting at index. |
| `Delete()` | Remove every image (alias for Clear). |
| `Delete(index: int)` | Remove the image at the 1-based index. |
| `Delete(index: int, action: ImageDeleteAction)` | Remove the image at the 1-based index using the supplied action policy. |
| `Delete(name: string)` | Remove the image with the supplied resource name. |
| `Delete(name: string, action: ImageDeleteAction)` | Remove the named image using the supplied action policy. |
| `GetImageName(image: XImage)` | Return the resource name of the supplied image. |
| `Remove(item: XImage)` | Remove an image and report whether it was present. |
| `Replace(index: int, stream: Stream)` | Replace the image at the 1-based index with the supplied stream. |
| `Replace(index: int, stream: Stream, quality: int)` | Replace the image at the 1-based index with a JPEG re-encoded at the given quality. |
| `Replace(index: int, stream: Stream, quality: int, isBlackAndWhite: bool)` | Replace the image at the 1-based index with a JPEG re-encoded at the given quality, optionally rendering as black-and-white. |
| `GetEnumerator()` | Enumerator typed to XImage. |
| `GetByName(name: string)` | Get an image by its resource name (e.g., "Im0", "JI1a"). |

## See Also

- [Aspose.PDF for .NET — Enterprise API Reference](https://reference.aspose.com/pdf/net/)