# Image

`Image` is a content element that contains an [ImageSource](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/model/imagesource) and represents an image. You can add it to the `Content` collection of an `IContainerElement` such as [RadFixedPage](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/model/radfixedpage).

## Public API

| **Property**    | **Description**                                                                                                                                                                 |
| --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ImageSource`   | Specifies the [ImageSource](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/model/imagesource) that the Image object visualizes. |
| `Width`         | The width of the image.                                                                                                                                                         |
| `Height`        | The height of the image.                                                                                                                                                        |
| `Position`      | The [Position](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/concepts/position) of the image inside the `IContainerElement`.   |
| `AlphaConstant` | Specifies the constant shape or constant opacity value for nonstroking operations.                                                                                              |

| **Method**                                         | **Description**                                                                                                                          |
| -------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| `GetBitmapSource` (not available in .NET Standard) | Creates a [BitmapSource](https://learn.microsoft.com/en-us/dotnet/api/system.windows.media.imaging.bitmapsource) from the image element. |
| `Clone` (starting with Q2 2025)                    | Creates a deep copy of this document element.                                                                                            |

### Working with an Image

You can edit an `Image` element using the properties the class exposes. The properties are listed in the [Public API](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/model/image#public-api) section.

> note Starting with **Q3 2024** RadPdfProcessing provides support for SVG FormSource (vector graphics image format): [Adding SVG FormSource into a Document](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/model/formsource/svg).

**Example 1** shows how to initialize an `Image` object, assign an `ImageSource` to it, and add it to a previously defined container (page).

**Example 1: Create image**

```C#
RadFixedDocument fixedDocument = new RadFixedDocument();
RadFixedPage fixedPage = fixedDocument.Pages.AddPage();

Telerik.Documents.Fixed.Model.Objects.Image img = new Telerik.Documents.Fixed.Model.Objects.Image();
string imageFilePath = "ProgressNinjas.png";
using (FileStream fileStream = new FileStream(imageFilePath, FileMode.Open))
{
    ImageSource imageSrc = new ImageSource(fileStream);
    img.ImageSource = imageSrc;
    img.Width = 200;
    img.Height = 200;
    img.AlphaConstant = 0.5;
    SimplePosition simplePosition = new SimplePosition();
    simplePosition.Translate(200, 300);
    img.Position = simplePosition;
    fixedPage.Content.Add(img);
}
```

Once you [export](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/formats-and-conversion/pdf/pdfformatprovider/pdfformatprovider) the `RadFixedDocument`, the following document with an image is created:

![RadPdfProcessing Image in RadFixedPage](https://www.telerik.com/document-processing-libraries/documentation/assets/eeaafbf292a732833c0f71208d8a78bd/pdf-processing-image.png)

**Example 2** demonstrates how to use one of the factory methods of the `ContentElementCollection` to create a new image and insert it into the respective container.

**Example 2: Add image to container**

```C#
ImageSource imageSource;
string filename = "my-image.png";
using (FileStream fileSource = File.Open(filename, FileMode.Open))
{
    imageSource = new ImageSource(fileSource);
}

Telerik.Documents.Fixed.Model.Objects.Image emptyImage = container.Content.AddImage();
Telerik.Documents.Fixed.Model.Objects.Image imageWithSource = container.Content.AddImage(imageSource);
```

> tip There are other methods that allow adding an image to a document by passing image size, format, and source. You can use them through the [FixedContentEditor](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/editing/fixedcontenteditor) class.

The `Image` class also exposes the `GetBitmapSource()` method, which allows you to obtain a [BitmapSource](https://learn.microsoft.com/en-us/dotnet/api/system.windows.media.imaging.bitmapsource) instance representing the image.

> The `GetBitmapSource()` method is not available in the .NET Standard version of the PdfProcessing packages.

**Obtain BitmapSource**

```C#
BitmapSource source = imageWithSource.GetBitmapSource();
```

## See Also

* [ImageSource](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/model/imagesource)
* [RadFixedPage](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/model/radfixedpage)
* [FixedContentEditor](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/editing/fixedcontenteditor)
* [Position](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/concepts/position)
* [How to Generate a PDF Document from Images with FixedContentEditor](https://www.telerik.com/document-processing-libraries/documentation/knowledge-base/pdf-from-images-with-fixedcontenteditor)
* [How to Generate a PDF Document from Images with RadFixedDocumentEditor](https://www.telerik.com/document-processing-libraries/documentation/knowledge-base/pdf-from-images-with-radfixeddocumenteditor)
* [Change File Size of a PDF with Images Through ImageCompression and ImageQuality](https://www.telerik.com/document-processing-libraries/documentation/knowledge-base/pdfprocessing-change-file-size-through-image-quality-and-compression)
* [Adding Images with a Shadow in PDF Documents](https://www.telerik.com/document-processing-libraries/documentation/knowledge-base/add-shadow-image-radpdfprocessing)
* [Splitting a Large Image Across Multiple PDF Pages](https://www.telerik.com/document-processing-libraries/documentation/knowledge-base/split-export-large-image-multiple-pdf-pages-radpdfprocessing)
* [Adding a Barcode to a PDF Document Using PdfProcessing and the WinForms BarcodeView](https://www.telerik.com/document-processing-libraries/documentation/knowledge-base/add-barcode-to-pdf-telerik)
* [Adding an Image Border in PdfProcessing](https://www.telerik.com/document-processing-libraries/documentation/knowledge-base/pdf-image-border)
* [Adding a .HEIC Image to PDF Documents in PdfProcessing](https://www.telerik.com/document-processing-libraries/documentation/knowledge-base/convert-heic-images-to-jpg)
* [Copying Images from RadFixedDocument to Windows Clipboard](https://www.telerik.com/document-processing-libraries/documentation/knowledge-base/extract-images-radfixeddocument-windows-clipboard-to-ms-word)
