Skip to content

Commit

Permalink
First Update
Browse files Browse the repository at this point in the history
  • Loading branch information
mojtabaJ committed Jul 31, 2022
1 parent 4880242 commit e3e1b5f
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 13 deletions.
26 changes: 24 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,33 @@ A simple compression utility for converting images (jpeg, png, tiff) to **WebP*
<dependency>
<groupId>io.github.mojtabaj</groupId>
<artifactId>c-webp</artifactId>
<version>1.0.1</version>
<version>1.0.2</version>
</dependency>
```

---


### Usage

```java
//Use WebpConverter for converting image to webp byte with 80 quality
byte[] webpByte = WebpConverter.imageByteToWebpByte(imageByteArray, 80);
byte[] webpByte = WebpConverter.imageFileToWebpByte("../inputImage.png", 80);

//Use WebpConverter for converting image to webp file with 80 quality
File webpFile = WebpConverter.imageByteToWebpFile(imageByteArray,"../outputImage.webp", 80);
File webpFile = WebpConverter.imageFileToWebpFile("../inputImage.png","../outputImage.webp", 80);


//Use CWebp to create and execute cwebp command to compress an image using the WebP format.
CWebp cwebp = new CWebp()
.input(imageFilePath) // specify the input file.
.quality(80) //factor for RGB channels
.resize(512, 512) // resize the source to a rectangle with size width x height.
.output(outputFilePath); // specify the output WebP file
cwebp.execute(); // executes the specified string command in a separate process.
```


License
=======
Expand Down
Binary file removed c-webp-1.0.0.jar
Binary file not shown.
22 changes: 11 additions & 11 deletions src/main/java/io/github/mojtabaJ/cwebp/WebpConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
* All Rights Reserved.
*
*
* util fot create and execute cwebp command to compresses an image using the WebP format.
* util for create and execute cwebp command to compresses an image using the WebP format.
* Input format can be either PNG, JPEG, TIFF, WebP or raw Y'CbCr samples.
* Note: Animated PNG and WebP files are not supported.
*/
public class WebpConverter {


/**
* convert PNG, JPEG, TIFF, WebP image to WebP Byte
* converting PNG, JPEG, TIFF, WebP image to WebP Byte
* @param imageByte input image byte
* @return WebP image Byte
*/
Expand All @@ -30,7 +30,7 @@ public static byte[] imageByteToWebpByte(byte[] imageByte){
}

/**
* convert PNG, JPEG, TIFF, WebP image to WebP Byte
* converting PNG, JPEG, TIFF, WebP image to WebP Byte
* @param imageByte input image byte
* @param quality compression factor for RGB channels
* @return WebP image Byte
Expand Down Expand Up @@ -59,7 +59,7 @@ public static byte[] imageByteToWebpByte(byte[] imageByte, int quality){
}

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

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


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

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

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

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


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

/**
* convert PNG, JPEG, TIFF, WebP image to WebP File
* converting PNG, JPEG, TIFF, WebP image to WebP File
* @param imageFilePath input image file path
* @param quality compression factor for RGB channels
* @param tempDir temp directory for converting
Expand Down

0 comments on commit e3e1b5f

Please sign in to comment.