'How to extract an image from PDF with Telerik Document Processing and ImageSharp?

I need to decode a PDF image with Telerik Document Processing and ImageSharp in a .NET Standard project.

private static IMAGE_SHARP.Image<Rgba32> ParseImageAsync(TELERIK_FIXED.Model.Objects.Image image)
{
    TELERIK_FIXED.Model.Resources.EncodedImageData imageData = image.ImageSource.GetEncodedImageData();

    bool isTransperant = imageData.AlphaChannel != null;
    if (imageData.Filters.Contains("DCTDecode") && !isTransperant)
    {
        return IMAGE_SHARP.Image.Load<Rgba32>(imageData.Data);
    }
    else if (imageData.Filters.Contains("JPXDecode"))
    {
        return IMAGE_SHARP.Image.Load<Rgba32>(imageData.Data);
    }
    else if (imageData.Filters.Contains("FlateDecode") || isTransperant)
    {
        // TODO: image.GetBitmapSource() method is not available in the .NET Standard version
        throw new NotImplementedException();
    }
    else
    {
        throw new NotSupportedException();
    }
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source