# ImageCollection Class

> An instance of the ImageCollection class contains all images in a Text Control document or part of the document represented through objects of the type Image. An instance of this class can be obtained with the TextControl.Images, HeaderFooter.Images or TextFrame.Images property. The ImageCollection class implements the IEnumerable and the ICollection interfaces.

- **Product:** TX Text Control .NET for WPF
- **Section:** Reference
- **Kind:** Class
- **Namespace:** `TXTextControl`
- **Package:** `TXTextControl.TextControl.WPF.SDK` (assembly `TXTextControl.dll`, from the private NuGet feed or Text Control Offline Packages)
- **.NET Framework:** reference `TXTextControl.dll` from the setup
- **Inherits:** `TXTextControl.FrameBaseCollection`
- **Implements:** `System.Collections.ICollection`, `System.Collections.IEnumerable`
- **Path:** TX Text Control .NET for WPF > Reference > TXTextControl > ImageCollection Class
- **1671 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/imagecollection/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/imagecollection/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/imagecollection/llms-full.txt

---

### Description

An instance of the ImageCollection class contains all images in a Text Control document or part of the document represented through objects of the type [Image](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/image/llms-full.txt). An instance of this class can be obtained with the [TextControl.Images](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/textcontrol/images-property/llms-full.txt), [HeaderFooter.Images](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/headerfooter/images-property/llms-full.txt) or [TextFrame.Images](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/textframe/images-property/llms-full.txt) property. The ImageCollection class implements the IEnumerable and the ICollection interfaces.

### Syntax

```csharp
public sealed class ImageCollection : FrameBaseCollection
```

```vbnet
Public NotInheritable Class ImageCollection
    Inherits FrameBaseCollection
```

### Examples

The following example iterates all images and sets the [Image.SaveMode](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/image/savemode-property/llms-full.txt) to SaveAsFileReference, so that all images will be exported the next time the document is saved. The images, will be saved in a subfolder called "'document name'\_Images" of the location where the document has been saved to. The additional properties can be used to set the image's quality, format and maximum resolution.

```csharp
foreach (TXTextControl.Image myImage in textControl1.Images)
{
  myImage.SaveMode = TXTextControl.ImageSaveMode.SaveAsFileReference;
  myImage.ExportCompressionQuality = 100; //Export with maximum quality
  myImage.ExportFilterIndex = 4; //Export as PNG format
  myImage.ExportMaxResolution = 96; //Export with 96 DPI max
}
```

```vbnet
For Each MyImage As TXTextControl.Image In TextControl1.Images
  MyImage.SaveMode = TXTextControl.ImageSaveMode.SaveAsFileReference
  MyImage.ExportCompressionQuality = 100 'Export with maximum quality
  MyImage.ExportFilterIndex = 3 'Export as PNG
  MyImage.ExportMaxResolution = 96 'Export with 96 DPI max
Next
```

The following example works with images in the current document.

```csharp
ImageCollection imageCollection = textControl.Images;
imageCollection.Add(new TXTextControl.Image { FileName = @"Images\company-logo.png", Name = "CompanyLogo" }, -1);
```

```vbnet
Dim imageCollection As ImageCollection = textControl.Images
imageCollection.Add(New TXTextControl.Image With { .FileName = "Images\company-logo.png", .Name = "CompanyLogo" }, -1)
```

---

## In This Section

- [ImageCollection.Add Method](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/imagecollection/add-method/llms-full.txt): Inserts a new image in a Text Control document.
- [ImageCollection.CopyTo Method](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/imagecollection/copyto-method/llms-full.txt): Copies the elements of the collection to an array, starting at a particular index.
- [ImageCollection.ExportFilters Property](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/imagecollection/exportfilters-property/llms-full.txt): Gets all available filters for exporting images. This property can be used to set the FileDialog.Filter property.
- [ImageCollection.GetItem Method](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/imagecollection/getitem-method/llms-full.txt): Gets a particular image from the collection.
- [ImageCollection.ImportFilters Property](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/imagecollection/importfilters-property/llms-full.txt): Gets all available filters for importing images. This property can be used to set the FileDialog.Filter property.
- [ImageCollection.Remove Method](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/imagecollection/remove-method/llms-full.txt): Removes an image from a Text Control document.

---

## Nearby

- **Previous:** [Image.VerticalScaling Property](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/image/verticalscaling-property/llms-full.txt)
- **Next:** [ImageCollection.Add Method](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/imagecollection/add-method/llms-full.txt)
