**EPPlus supports adding/modifying/removing pictures on worksheets. Pictures are accessed via `ExcelWorksheet`'s `Drawings` property and you can add them via a file path, a `FileInfo` instance or a `Stream`. You can also add a hyperlink to a picture by supplying an `Uri` or an `ExcelHyperlink` to the `AddPicture` method.**

### The AddPicture method

Pictures are added to worksheets via the `AddPicture` method, which is accessed via the `Drawings` property on `ExcelWorksheet`. This method has many overloads and returns an `ExcelPicture` instance. Via the properties of `ExcelPicture` you can set properties like size, border, fill and other effects.

The `ExcelPicture` class also has an `Image` property that represents the actual image. See [the ExcelImage class](<#the-excelimage-class>) below.

There are async versions of `AddPicture`, these are named `AddPictureAsync`.

### Example

Adding a picture/image to the workbook will work in a very similar way as adding a [Shape](<https://epplussoftware.com/docs/charts-and-drawing-objects/shapes/index.md>)

```csharp
//Add a jpg image and apply some effects (EPPlus 6+ interface).
var pic = worksheet.Drawings.AddPicture("Landscape", new FileInfo("c:\\temp\\LandscapeView.jpg"));
pic.SetPosition(2, 0, 1, 0);
pic.Effect.SetPresetShadow(ePresetExcelShadowType.OuterBottomRight);
pic.Effect.OuterShadow.Distance = 10;
pic.Effect.SetPresetSoftEdges(ePresetExcelSoftEdgesType.SoftEdge5Pt);
```

```vbnet
'Add a jpg image and apply some effects (EPPlus 6+ interface).
Dim pic = worksheet.Drawings.AddPicture("Landscape", New FileInfo("c:\temp\LandscapeView.jpg"))
pic.SetPosition(2, 0, 1, 0)
pic.Effect.SetPresetShadow(ePresetExcelShadowType.OuterBottomRight)
pic.Effect.OuterShadow.Distance = 10
pic.Effect.SetPresetSoftEdges(ePresetExcelSoftEdgesType.SoftEdge5Pt)
```

### Read existing pictures

```csharp
var pics = worksheet.Drawings.Where(x => x.DrawingType == eDrawingType.Picture).Select(x => x.As.Picture);
foreach(var pic in pics)
{
    var name = pic.Name;
    var imageType = pic.Image.Type;
    var width = pic.Image.Bounds.Width;
    // etc
}
```

```vbnet
Dim pics = worksheet.Drawings.Where(Function(x) x.DrawingType = eDrawingType.Picture).Select(Function(x) x.As.Picture)
For Each pic In pics
    Dim name = pic.Name
    Dim imageType = pic.Image.Type
    Dim width = pic.Image.Bounds.Width
    ' etc
Next
```

### Re-arrange vertically

As with any other `Drawing` you can use the `SendToBack` and `BringToFront` methods to adjust how a Picture is located vertically compared with other `Drawings`.

```csharp
pic.BringToFront();
// or
pic.SendToBack();
```

```vbnet
pic.BringToFront()
' or
pic.SendToBack()
```

### Remove a Picture

You can remove a shape from a worksheet via the `Drawings.Remove` method.

```csharp
// remove by instance
var itemToRemove = worksheet.Drawings.FirstOrDefault(x => x.Name == "myPic");
if(itemToRemove != null)
{
    worksheet.Drawings.Remove(itemToRemove);
}

// remove by index
worksheet.Drawings.Remove(0);

// remove by name
worksheet.Drawings.Remove("myPic");
```

```vbnet
' remove by instance
Dim itemToRemove = worksheet.Drawings.FirstOrDefault(Function(x) x.Name = "myPic")
If itemToRemove IsNot Nothing Then
    worksheet.Drawings.Remove(itemToRemove)
End If

' remove by index
worksheet.Drawings.Remove(0)

' remove by name
worksheet.Drawings.Remove("myPic")
```

### The `ExcelImage` class

From EPPlus 6, the `ExcelImage` class replaces all `System.Drawing.Common.Image` properties (see list above).

#### Constructors

| Name | Description |
| --- | --- |
| `ExcelImage()` | Creates an `ExcelImage` to be used as template for adding images. Use the `SetImage` methods to load the image after initialization |
| `ExcelImage(string imagePath)` | Creates an `ExcelImage` and loads an image from file. |
| `ExcelImage(FileInfo imageFile)` | Creates an `ExcelImage` and loads an image from file. |
| `ExcelImage(Stream imageStream, ePictureType pictureType)` | Creates an `ExcelImage` from a stream. |
| `ExcelImage(byte[] imageBytes, ePictureType pictureType)` | Creates an `ExcelImage` from a byte array. |
| \#\#\#\# Properties |  |
| These properties are all readonly. |  |

| Name | Data type | Description |
| --- | --- | --- |
| `ImageBytes` | `byte[]` | The image as a byte-array |
| `Type` | `ePictureType` | The type of image, for example jpg, gif or svg |
| `Bounds` | `ExcelImageInfo` | The bounds and resolution of the image |

#### Methods

| Name | Description |
| --- | --- |
| `SetImage(string)` | Sets the image from a file path |
| `SetImage(FileInfo)` | Sets the image from a FileInfo object |
| `SetImage(byte[], ePictureType)` | Sets the image from a byte array |
| `SetImage(Stream, ePictureType)` | Sets the image from a stream |
| `SetImage(ExcelImage)` | Sets the image from another image object |
| `SetImageAsync(string)` | Sets the image from a file path |
| `SetImageAsync(FileInfo)` | Sets the image from a FileInfo object |
| `SetImageAsync(Stream, ePictureType)` | Sets the image from a stream |
| \#\# See also |  |
| [Sample 5.1 (C\#)](<https://github.com/EPPlusSoftware/EPPlus.Samples.CSharp/tree/master/05-Drawings charts and themes/01-Shapes and images>) or [Sample 5.1 (VB)](<https://github.com/EPPlusSoftware/EPPlus.Samples.VB/tree/master/05-Drawings charts and themes/01-Shapes and images>) |  |
