Skip to content

Commit e3e1b5f

Browse files
committed
First Update
1 parent 4880242 commit e3e1b5f

File tree

3 files changed

+35
-13
lines changed

3 files changed

+35
-13
lines changed

README.md

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,33 @@ A simple compression utility for converting images (jpeg, png, tiff) to **WebP*
1414
<dependency>
1515
<groupId>io.github.mojtabaj</groupId>
1616
<artifactId>c-webp</artifactId>
17-
<version>1.0.1</version>
17+
<version>1.0.2</version>
1818
</dependency>
1919
```
2020

21-
---
21+
22+
23+
### Usage
24+
25+
```java
26+
//Use WebpConverter for converting image to webp byte with 80 quality
27+
byte[] webpByte = WebpConverter.imageByteToWebpByte(imageByteArray, 80);
28+
byte[] webpByte = WebpConverter.imageFileToWebpByte("../inputImage.png", 80);
29+
30+
//Use WebpConverter for converting image to webp file with 80 quality
31+
File webpFile = WebpConverter.imageByteToWebpFile(imageByteArray,"../outputImage.webp", 80);
32+
File webpFile = WebpConverter.imageFileToWebpFile("../inputImage.png","../outputImage.webp", 80);
33+
34+
35+
//Use CWebp to create and execute cwebp command to compress an image using the WebP format.
36+
CWebp cwebp = new CWebp()
37+
.input(imageFilePath) // specify the input file.
38+
.quality(80) //factor for RGB channels
39+
.resize(512, 512) // resize the source to a rectangle with size width x height.
40+
.output(outputFilePath); // specify the output WebP file
41+
cwebp.execute(); // executes the specified string command in a separate process.
42+
```
43+
2244

2345
License
2446
=======

c-webp-1.0.0.jar

-7.13 KB
Binary file not shown.

src/main/java/io/github/mojtabaJ/cwebp/WebpConverter.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313
* All Rights Reserved.
1414
*
1515
*
16-
* util fot create and execute cwebp command to compresses an image using the WebP format.
16+
* util for create and execute cwebp command to compresses an image using the WebP format.
1717
* Input format can be either PNG, JPEG, TIFF, WebP or raw Y'CbCr samples.
1818
* Note: Animated PNG and WebP files are not supported.
1919
*/
2020
public class WebpConverter {
2121

2222

2323
/**
24-
* convert PNG, JPEG, TIFF, WebP image to WebP Byte
24+
* converting PNG, JPEG, TIFF, WebP image to WebP Byte
2525
* @param imageByte input image byte
2626
* @return WebP image Byte
2727
*/
@@ -30,7 +30,7 @@ public static byte[] imageByteToWebpByte(byte[] imageByte){
3030
}
3131

3232
/**
33-
* convert PNG, JPEG, TIFF, WebP image to WebP Byte
33+
* converting PNG, JPEG, TIFF, WebP image to WebP Byte
3434
* @param imageByte input image byte
3535
* @param quality compression factor for RGB channels
3636
* @return WebP image Byte
@@ -59,7 +59,7 @@ public static byte[] imageByteToWebpByte(byte[] imageByte, int quality){
5959
}
6060

6161
/**
62-
* convert PNG, JPEG, TIFF, WebP image to WebP Byte
62+
* converting PNG, JPEG, TIFF, WebP image to WebP Byte
6363
* @param imageFilePath input image file path
6464
* @param quality compression factor for RGB channels
6565
* @return WebP image Byte
@@ -79,7 +79,7 @@ public static byte[] imageFileToWebpByte(String imageFilePath, int quality) {
7979
}
8080

8181
/**
82-
* convert PNG, JPEG, TIFF, WebP image to WebP Byte
82+
* converting PNG, JPEG, TIFF, WebP image to WebP Byte
8383
* @param imageFile input image file
8484
* @param quality compression factor for RGB channels
8585
* @return WebP image Byte
@@ -91,7 +91,7 @@ public static byte[] imageFileToWebpByte(File imageFile, int quality) {
9191

9292

9393
/**
94-
* convert PNG, JPEG, TIFF, WebP image to WebP File
94+
* converting PNG, JPEG, TIFF, WebP image to WebP File
9595
* @param imageByte input image byte
9696
* @param webpPathFile output webp image path file
9797
* @return WebP image File
@@ -101,7 +101,7 @@ public static File imageByteToWebpFile(byte[] imageByte, String webpPathFile){
101101
}
102102

103103
/**
104-
* convert PNG, JPEG, TIFF, WebP image to WebP File
104+
* converting PNG, JPEG, TIFF, WebP image to WebP File
105105
* @param imageByte input image byte
106106
* @param webpPathFile output webp image path file
107107
* @param quality compression factor for RGB channels
@@ -130,7 +130,7 @@ public static File imageByteToWebpFile(byte[] imageByte, String webpPathFile, in
130130
}
131131

132132
/**
133-
* convert PNG, JPEG, TIFF, WebP image to WebP File
133+
* converting PNG, JPEG, TIFF, WebP image to WebP File
134134
* @param imageFilePath input image file path
135135
* @param webpPathFile output webp image path file
136136
* @param quality compression factor for RGB channels
@@ -146,7 +146,7 @@ public static File imageFileToWebpFile(String imageFilePath, String webpPathFile
146146
}
147147

148148
/**
149-
* convert PNG, JPEG, TIFF, WebP image to WebP File
149+
* converting PNG, JPEG, TIFF, WebP image to WebP File
150150
* @param imageFile input image file
151151
* @param webpPathFile output webp image path file
152152
* @param quality compression factor for RGB channels
@@ -159,7 +159,7 @@ public static File imageFileToWebpFile(File imageFile, String webpPathFile, int
159159

160160

161161
/**
162-
* convert PNG, JPEG, TIFF, WebP image to WebP Byte
162+
* converting PNG, JPEG, TIFF, WebP image to WebP Byte
163163
* @param imageFilePath input image file path
164164
* @param quality compression factor for RGB channels
165165
* @param tempDir temp directory for converting
@@ -179,7 +179,7 @@ private static byte[] getWebpBytes(String imageFilePath, int quality, Path tempD
179179
}
180180

181181
/**
182-
* convert PNG, JPEG, TIFF, WebP image to WebP File
182+
* converting PNG, JPEG, TIFF, WebP image to WebP File
183183
* @param imageFilePath input image file path
184184
* @param quality compression factor for RGB channels
185185
* @param tempDir temp directory for converting

0 commit comments

Comments
 (0)