[opencms-dev] Reading dimensions of an image

Robert Weber rw at clt.ag
Fri Nov 30 15:43:23 CET 2012


Hi Rüdiger,

thanks - I just found this :)

Anyway I would like to know what is wrong with my code.

Cheers
Robert

Am 30.11.2012 um 15:40 schrieb Rüdiger Kurz:

> Hi Robert,
> 
> by default OpenCms stores the dimension into the property 'image.size' after uploading a image.
> 
> Maybe that will help ...
> 
> regards
> Rüdiger
> 
> On 30.11.2012 15:36, Robert Weber wrote:
>> Hi List,
>> 
>> I am trying to read the dimensions of an image within VFS, but this code:
>> 
>> CmsResource res = cmso.readResource(pageContext.getAttribute("image").toString());
>> CmsFile file = new CmsFile(res);
>> InputStream in = new ByteArrayInputStream(file.getContents());
>> BufferedImage bimg = ImageIO.read(in);
>> int width          = bimg.getWidth();
>> 
>> 
>> Is not working as I get an NullPointerException. Can anyone help?
>> 
>> Cheers
>> Robert
> 
> 
> -- 
> Kind Regards,
> Rüdiger.
> 
> -------------------
> 
> Rüdiger Kurz
> 
> Alkacon Software GmbH  - The OpenCms Experts
> http://www.alkacon.com - http://www.opencms.org




More information about the opencms-dev mailing list