This project webp-imageio-core may help you.
It integrates webp converter native system libs(dll/so/dylib).
Download it and import to you project. Example code:
public static void main(String args[]) throws IOException {
String inputWebpPath = "test_pic/test.webp";
String outputJpgPath = "test_pic/test_.jpg";
String outputJpegPath = "test_pic/test_.jpeg";
String outputPngPath = "test_pic/test_.png";
// Obtain a WebP ImageReader instance
ImageReader reader = ImageIO.getImageReadersByMIMEType("image/webp").next();
// Configure decoding parameters
WebPReadParam readParam = new WebPReadParam();
readParam.setBypassFiltering(true);
// Configure the input on the ImageReader
reader.setInput(new FileImageInputStream(new File(inputWebpPath)));
// Decode the image
BufferedImage image = reader.read(0, readParam);
ImageIO.write(image, "png", new File(outputPngPath));
ImageIO.write(image, "jpg", new File(outputJpgPath));
ImageIO.write(image, "jpeg", new File(outputJpegPath));
}
Then you can using ImageIO that extracts the size from headers.