Pergunta

Is there a way to check to see if a renderedOp is corrupt without rendering it?

I have a site where users upload an image, and I need to verify that it isn't a corrupt image. Currently I can do that by doing the following:

try{
   RenderedOp imageOp = JAI.create("stream", inputStream);
   imageOp.getRendering();
} catch (Exception e) {
   //Image is corrupt/can't be rendered
}

Is there a different way? Rendering takes longer than I want it to, which is why I'm asking.

Foi útil?

Solução

I believe the only way to see if an image is valid or not is by rendering it and seeing if the value returned is null, which means it could not be rendered. Either that or it should throw an exception, as you have. There are many methods that render an image, like getHeight and getWidth.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top