Results 1 to 4 of 4

Thread: How to get the image size (width and height)?

  1. #1
    Join Date
    Jul 2011
    Posts
    3

    Default How to get the image size (width and height)?

    Hi, I am new to grails. I spent fare amount of time in search of finding the image size using grails but end up with nothing.
    I want to find the image size (width and height) using grails by just giving path of the image. Is it possible using grails? if yes, how?
    Please suggest me easy way to find the image size.

    Thanks in advance,
    Venkatesh

  2. #2
    Join Date
    Jul 2011
    Posts
    3

    Default

    Any help is appreciated...

  3. #3
    Join Date
    Jun 2010
    Location
    London
    Posts
    304

    Default

    What image size? Is this a static resource under web-app/images of the application? Or is it an image upload? Or is it an image elsewhere? Regardless, you should have a look at the Burning Image plugin, which I believe makes it pretty easy to access this information.

  4. #4
    Join Date
    Jul 2011
    Posts
    3

    Default

    thanks for your reply.
    Ya it is a static resource under web-app/images of the application.
    I found the solution as well, it is as shown below -

    import java.awt.image.BufferedImage;
    import java.io.File;
    import javax.imageio.ImageIO;
    ...

    def img = ImageIO.read(new File("path/to/your/file/cherry.jpg"));
    println("Width:"+img.getWidth()+" Height:"+img.getHeight());

    I think it is too late response from the forum.

    Regards,
    Venkatesh

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •