Question

I have a requirement to be be able to embed scanned tiff images into some SSRS reports.

When I design a report in VS2005 and add an image control the tiff image displays perfectly however when I build it. I get the warning :

Warning 2 [rsInvalidMIMEType] The value of the MIMEType property for the image ‘image1’ is “image/tiff”, which is not a valid MIMEType. c:\SSRSStuff\TestReport.rdl 0 0

and instead of an image I get the little red x.

Has anybody overcome this issue?

Was it helpful?

Solution

Assuming you're delivering the image file via IIS, use an ASP.NET page to change image formats and mime type to something that you can use.

Response.ContentType = "image/png";
Response.Clear();
using (Bitmap bmp = new Bitmap(tifFilepath))
  bmp.Save(Response.OutputStream, ImageFormat.Png);
Response.End();

OTHER TIPS

I have been goggling fora solution on how to display a TIFF image in a SSRS report but I couldn't find any and since SSRS doesn's support TIFF, I thought converting the TIFF to one of the suppported format will do the trick. And it did. I don't know if there are similar implementation like this out there, but I am just posting so others could benefit as well. Note this only applies if you have a TIFF image saved on database.

Public Shared Function ToImage(ByVal imageBytes As Byte()) As Byte()
    Dim ms As System.IO.MemoryStream = New System.IO.MemoryStream(imageBytes)
    Dim os As System.IO.MemoryStream = New System.IO.MemoryStream()
    Dim img As System.Drawing.Image = System.Drawing.Image.FromStream(ms)

    img.Save(os, System.Drawing.Imaging.ImageFormat.Jpeg)

    Return os.ToArray()
End Function

Here’s how you can use the code: 1. In the Report Properties, Select Refereneces, click add and browse System.Drawing, Version=2.0.0.0 2. Select the Code Property, Copy paste the function above 3. Click Ok 4. Drop an Image control from the toolbox 4.1. Right-Click the image and select Image Properties 4.2. Set the Image Source to Database 4.3. In the Use this field, Click expression and paste the code below =Code.ToImage(Fields!FormImage.Value)
4.4. Set the appropriate Mime to Jpeg

Regards, Fulbert

Thanks Peter your code didn't compile but the idea was sound.

Here is my attempt that works for me.

protected void Page_Load(object sender, EventArgs e)
{
    Response.ContentType = "image/jpeg";
    Response.Clear();        
    Bitmap bmp = new Bitmap(tifFileLocation);
    bmp.Save(Response.OutputStream, ImageFormat.Jpeg);
    Response.End();

}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top