Available for: UI for Blazor | UI for Xamarin | UI for WinUI | UI for ASP.NET Core | UI for .NET MAUI

New to Telerik Document Processing? Download free 30-day trial

Exporting Images in .NET Standard

.NET Standard specification does not define APIs for getting the image properties. SpreadProcessing needs to have access to GDI+ basic graphics functionality when exporting spreadsheets that contain images. That is why, to allow the library to get the image properties needed for saving the workbook, an implementation inheriting the ImagePropertiesResolverBase abstract class must be set to the ImagePropertiesResolver property of SpreadExtensibilityManager.

The Telerik.Documents.ImageUtils assembly provides a default implementation of the ImagePropertiesResolver class that could be used when exporting the document.

Example 1: Set the default implementation of the ImagePropertiesResolver class

ImagePropertiesResolverBase imagePropertiesResolver = new ImagePropertiesResolver(); 
SpreadExtensibilityManager.ImagePropertiesResolver = imagePropertiesResolver; 

Example 2: Windows Example: Create a custom implementation inheriting the ImagePropertiesResolverBase abstract class

public class ImageInfo : ImagePropertiesResolverBase 
{ 
    public override Size GetImageSize(byte[] imageData) 
    { 
        MemoryStream stream = new MemoryStream(imageData); 
        using (var image = new System.Drawing.Bitmap(stream)) 
        { 
            return new Size(image.Width, image.Height); 
        } 
    } 
} 

Example 3: Set the custom implementation inheriting the ImagePropertiesResolverBase abstract class

ImagePropertiesResolverBase imagePropertiesResolver = new ImageInfo(); 
SpreadExtensibilityManager.ImagePropertiesResolver = imagePropertiesResolver; 

See Also

In this article