Possible to extract Embedded image to a file?

…衆ロ難τιáo~ 提交于 2019-12-05 01:47:47

Two approaches are detailed in this blog post:

  1. Copy the encoded image from one report to another if you need to reuse it there.
  2. Export a copy of the report to Excel and copy the image from the spreadsheet.

Or if you need access to the image more directly, I found this utility that will parse the XML and load and export the images. Looks like source code is available.

Fabian

I 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.

I just needed to do this and realised that it is possible to cut and paste the embedded image, even though it is not possible to copy and paste.

  1. Open the XML (in notepad++ or anything)
  2. Look for the <ImageData></ImageData> tags
  3. Copy the 64-bit encoded string between the tags
  4. Find a utility to convert x64 encoded strings to files. I used this website and downloaded the image
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!