Forum Discussion

dablackgoku1234's avatar
dablackgoku1234
Occasional Contributor
9 years ago

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

     

  • KarelHusa's avatar
    KarelHusa
    Champion Level 2

    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());