title: How to return an Image to browser in rest API in JAVA?
body: <p>I want to an image while I hit an API like <code>localhost:8080:/getImage/app/path={imagePath}</code></p>
  
  <p>While I hit this API it will return me an Image.</p>
  
  <p>Is this possible?</p>
  
  <p>Actually, I have tried this but it is giving me an ERROR.
  Here is my code,</p>
  
  <pre><code>@GET
  @Path("/app")
  public BufferedImage getFullImage(@Context UriInfo info) throws MalformedURLException, IOException {
      String objectKey = info.getQueryParameters().getFirst("path");
  
      return resizeImage(300, 300, objectKey);
  }
  
  
  public static BufferedImage resizeImage(int width, int height, String imagePath)
          throws MalformedURLException, IOException {
      BufferedImage bufferedImage = ImageIO.read(new URL(imagePath));
      final Graphics2D graphics2D = bufferedImage.createGraphics();
      graphics2D.setComposite(AlphaComposite.Src);
      // below three lines are for RenderingHints for better image quality at cost of
      // higher processing time
      graphics2D.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
      graphics2D.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
      graphics2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
      graphics2D.drawImage(bufferedImage, 0, 0, width, height, null);
      graphics2D.dispose();
      System.out.println(bufferedImage.getWidth());
      return bufferedImage;
  }
  </code></pre>
  
  <p>My ERROR,</p>
  
  <pre><code>java.io.IOException: The image-based media type image/webp is not supported for writing
  </code></pre>
  
  <p>Is there any way to return an Image while hitting any URL in java?</p>