Given a SSRS report definition file with an embedded image in it, just wondering if its possible to extract that image XML to recreate the original image file.
e.g. :
inside the rdlc file, you might see xml like this :
<EmbeddedImage Name="tick">
<MIMEType>image/bmp</MIMEType>
<ImageData>Qk1mAwAAAAAAADYAAAAoAAAAEAAAABEAAAABABgA ... <<REST OF IMAGE HERE>>
</ImageData>
</EmbeddedImage>
Is it possible to take the ImageData, and transform form it in some way to re-create the original image bitmap byte stream ?
(This might be useful in cases such as when you've lost the original image file on which the embedded image was based.)
<ImageData></ImageData>
tagsI have created a small Power Shell script to solve this problem:
$ErrorActionPreference = 'Stop';
Get-ChildItem -Filter '*.rdl' | ForEach {
$reportFile = $_;
Write-Host $reportFile;
$report = [xml](Get-Content $reportFile);
$report.Report.EmbeddedImages.EmbeddedImage | Foreach {
$imagexml = $_;
$imageextension = $imagexml.MIMEType.Split('/')[1];
$filename = $imagexml.Name + '.' + $imageextension;
Write-Host '->' $filename;
$imageContent = [System.Convert]::FromBase64String($imagexml.ImageData);
Set-Content -Path $filename -Encoding Byte -Value $imageContent;
}
}
https://gist.github.com/Fabian-Schmidt/71746e8e1dbdf9db9278
This script extracts all images from all reports in the current folder.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With