Forum Discussion

dablackgoku1234's avatar
dablackgoku1234
Occasional Contributor
8 years ago
Solved

Check Image size

I have a HTTP request step that checks the link of an image.  I am wondering if there is a way to check the resolution of the image based on that response?

  • You can check with a Groovy script test step:

     

    import javax.imageio.*
    
    def image = ImageIO.read('http://YourImageURL'.toURL())
    log.info "Width:"+ image.getWidth()+ " Height:" + image.getHeight()
    
    

    Karel

     

2 Replies

  • KarelHusa's avatar
    KarelHusa
    Champion Level 3

    You can check with a Groovy script test step:

     

    import javax.imageio.*
    
    def image = ImageIO.read('http://YourImageURL'.toURL())
    log.info "Width:"+ image.getWidth()+ " Height:" + image.getHeight()
    
    

    Karel

     

    • dablackgoku1234's avatar
      dablackgoku1234
      Occasional Contributor

      Thanks for the sniplet.

       

      For those using javascript:

       

       

      var url = new java.net.URL('http://YourImageURL');
      var image = javax.imageio.ImageIO.read(url);
      log.info(image.getWidth() + "x" + image.getHeight());