|
|
@@ -35,7 +35,7 @@ public class ImageOps {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- public static byte[] convert2jpg(File srcFile) throws IOException {
|
|
|
+ public static byte[] convert2jpeg(File srcFile) throws IOException {
|
|
|
ImageInputStream iis = ImageIO.createImageInputStream(srcFile);
|
|
|
BufferedImage image = ImageIO.read(iis);
|
|
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
|
|
@@ -44,6 +44,15 @@ public class ImageOps {
|
|
|
return baos.toByteArray();
|
|
|
}
|
|
|
|
|
|
+ public static byte[] convert2webp(File srcFile) throws IOException {
|
|
|
+ ImageInputStream iis = ImageIO.createImageInputStream(srcFile);
|
|
|
+ BufferedImage image = ImageIO.read(iis);
|
|
|
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
|
|
+ ImageOutputStream ios = ImageIO.createImageOutputStream(baos);
|
|
|
+ ImageIO.write(image, "webp", ios);
|
|
|
+ return baos.toByteArray();
|
|
|
+ }
|
|
|
+
|
|
|
public static byte[] png2jpg(File srcFile) throws IOException {
|
|
|
BufferedImage image = ImageIO.read(srcFile);
|
|
|
BufferedImage result = new BufferedImage(
|