Get Image Dimesions - Help

1
Hi Guys, Wondered if you could help with a custom java action. I want to create a custom java action to get the properties of an image (height and width), the overall goal is find out if its landscape or portrait (by looking at which length is greater in size), then setting the smallest length (if it isn't smaller then 900, to 900, then keeping the ratio of the other length). This is in an effort to compress the size of a stored image.   I can change the length because there is already something in the app store which can resize image, but i need the current image properties to idenifty if its a portait or landscape, then to keep the ratio when i reduce the size. I don't write java but have got as far as:     // BEGIN USER CODE         BufferedImage inputImage = ImageIO.read(new File(filename));          int width =  inputImage. getWidth();          int height = inputImage.getHeight();         // END USER CODE   But this returns an error of: ava.lang.Error: Unresolved compilation problems:      BufferedImage cannot be resolved to a type     ImageIO cannot be resolved     File cannot be resolved to a type     filename cannot be resolved to a variable   Any help is greatly appreciated!
asked
2 answers
1

The GetImageDimensions action in the Community Commons module probably serves your needs.

 

answered
0

Sometimes classes dont get loaded in

var ImageIO;
try{
    ImageIO=Java.type('javax.imageio.ImageIO');
}catch(e){
    java.lang.Thread.currentThread().getContextClassLoader().loadClass('javax.imageio.ImageIO');
    ImageIO=Java.type('javax.imageio.ImageIO');
}

Or restart a couple of times

answered