So setting up the SSRS report was pretty straight forward. In order to generate an image for each of the sales territories, I had to additionally create a Data-Driven Subscription, passing in the sales territory code into a report parameter. Again, pretty straight forward, until I realized that the only image export format available was a TIFF image file, which wouldn't work for the clients web page. They required a JPG or PNG.
The answer was to go ahead and generate the TIFFs using the subscription and then run this handy PowerShell script which would convert each image to a PNG:
#Load required assemblies and get object reference [Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms"); $path = "C:\MapImages" Get-ChildItem $path *.tif | ForEach-Object { $i = new-object System.Drawing.Bitmap($_.FullName); # Save with the image in the desired format $i.Save($("$($path)\$($_.BaseName).png"),"PNG"); }
This script loops through each of the TIFFs located in the specified path, opening them and then saving them with the specified PNG format with the same base name as the TIFF. Most of this tiny script can be credited to the Hey, Scripting Guy! Blog post Hey, Scripting Guy! How Can I Use Windows PowerShell to Convert Graphics Files to Different File Formats?
No comments:
Post a Comment