Question

I have a problem and I hope that you could help me. I'm using struts2 and I have an action like that:

<action name="myAction" method="cimas" class="MyClass" >
<result name="success" type="stream">
<param name="contentType">image/jpeg</param>
<param name="inputName">inputStream</param>
<param name="contentDisposition">inline;filename="${filename}"</param>
<param name="bufferSize">1024</param>
</result>
</action>

Until here everything's perfect, I set from my class the inputStream using this code:

filename = "anImage.jpg";
File img = new File("D://anImage.jpg");
inputStream = new FileInputStream(img);

and the image shows correctly, but the problem appears when I try to display an imagen with tif format. I change the path of the image, the filename and I set the contentType to:

<param name="contentType">image/tiff</param>

But it doesn't work and I wonder why. Can anybody help me?

Edit:

I edited the answer to explain what I did to resolve the problem.

As many users said to me, tiff format isn't for web use. Inspite of it, with IE and AlternaTIFF I accomplished to show the image. But as I wanted a solution for all browsers finally I converted the image to jpg and I displayed it using ImageMagick.

Thanks all for your help.

Était-ce utile?

La solution

The solution is convert it to JPEG, PNG, GIF, or SVG otherwise in long term it will have issues.

TIFF image format is not designed for web use; it’s used for printing. Examples of image formats for the web are JPEG, PNG, GIF, and SVG.

Why are certain image formats suitable for the web, while others aren’t? Because images on the web must be optimized and highly compressed so that they don’t get too huge.

Some digital image formats, especially those designed for print (such as TIFF) are so unnecessarily high in resolution, metadata, and color-richness — which all become irrelevant when viewed in computer monitors — that they are too big in file size for web use.

Autres conseils

Most browsers and email apps can not display TIFF images. Need to stick to PNG, JPG, or GIF for Web interfaces.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top