// The path to the documents directory. String dataDir = "D:/WebPImages/"; String inputFile = dataDir + "Animation1.webp"; String outputFile = dataDir + "Animation2.webp"; try (ByteArrayOutputStream ms = new ByteArrayOutputStream()) { try (WebPImage image = (WebPImage)Image.load(inputFile)) { image.resize(300, 450, ResizeType.HighQualityResample); image.crop(new Rectangle(10, 10, 200, 300)); image.rotateFlipAll(RotateFlipType.Rotate90FlipX); image.save(ms); } try (FileOutputStream fs = new FileOutputStream(outputFile)) { byte[] bytes = ms.toByteArray(); fs.write(bytes, 0, bytes.length); } }