What do you do when you want to re-use an image in one of those old forgotten reports that was developed by that weird guy who left your company an year ago? No matter how much you hate or abuse that guy now, it is not going to do you any good as he didn’t save those images in a source or version control mechanism. And you are left tearing your hair apart thinking on how to get those same images in your new reports. This was exactly the question that was asked by one of my blog readers and I thought of blogging down the solution for the benefit of others who might be in the same situation.
I have created a sample report using a beautiful image from Riez.Info and some statistics from the Peace Alliance.
Suppose you just have this report in your hand and no access to the original source images. There might be two scenarios that I can think of which are given below along with their solutions on how you would want to use the images :-
1) Re-use the image in a new report
For External and Database images, you can reuse the code (which is already working in the old report) and that should be fine (read How to: Add an Image (Reporting Services) on how to add images). However, for Embedded images, we will have to follow the steps below:-
1) Open the report in Business Intelligence Development Studio (BIDS). Then right click on the report in the solution explorer of BIDS and select view code.
2) Search for <EmbeddedImages> and copy all the code between <EmbeddedImages> and </EmbeddedImages>
3) Now click on the new report in the solution explorer and view it’s code. Paste the code copied from the step above in a relatively same position (or above </Report> if it is a new report).
4) Save it and close it. Now open the report once again and you should be able to see the images embedded in your new report and ready to use.
2) Save the images from a report to the hard drive
I had always thought the easiest way to do this would be to view the deployed report in Internet Explorer, right click on the image and select ‘Save image as’ option. Somehow, it didn’t work when I tried it out now. So the next easiest solution is given below:-
1) View the deployed report in Internet Explorer and select the Export as Excel option.
2) Save and open the Excel file and then copy the image that you need into an image editing tool like Microsoft Paint. Save it and you have the image with you
I found this blog link by Adam Pooler where he has coded an utility which does the job of extracting embedded images from SSRS reports. This would definitely make your life easy if you have lots of images and also, the image would not suffer any changes which can occur due to improper copying and pasting techniques which can happen in the technique mentioned above. Recommended.