https://github.com/ustc-zzzz/avif-imageio-native-reader
A native JNI binding for avif image format, which supports Java imageio service
https://github.com/ustc-zzzz/avif-imageio-native-reader
avif avif-animated avif-decoder heif imageio java
Last synced: about 1 month ago
JSON representation
A native JNI binding for avif image format, which supports Java imageio service
- Host: GitHub
- URL: https://github.com/ustc-zzzz/avif-imageio-native-reader
- Owner: ustc-zzzz
- License: lgpl-3.0
- Created: 2025-05-04T16:28:22.000Z (about 1 month ago)
- Default Branch: master
- Last Pushed: 2025-05-04T17:57:40.000Z (about 1 month ago)
- Last Synced: 2025-05-04T18:28:41.064Z (about 1 month ago)
- Topics: avif, avif-animated, avif-decoder, heif, imageio, java
- Language: Java
- Homepage:
- Size: 45.9 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# AVIF ImageIO Native Reader
[](https://jitpack.io/#ustc-zzzz/avif-imageio-native-reader)
A native JNI binding for avif image format, which supports Java imageio service.
This library requires Java 17 or above.
## Include Dependency
```groovy
// Add it in your root build.gradle at the end of repositories
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
// Add the dependency
dependencies {
implementation 'com.github.ustc-zzzz:avif-imageio-native-reader:master-SNAPSHOT'
}
```## Usage
```
$ jshell --class-path avif-imageio-native-reader.jar
| Welcome to JShell -- Version 17.0.15
| For an introduction type: /help introjshell> import javax.imageio.*
jshell> ImageIO.read(new File("paris_icc_exif_xmp.avif")) // still image
$2 ==> BufferedImage@6aceb1a5: type = 5 ColorModel: #pixelBits = 24 numComponents = 3 color space = java.awt.color.ICC_ColorSpace@2d6d8735 transparency = 1 has alpha = false isAlphaPre = false ByteInterleavedRaster: width = 403 height = 302 #numDataElements 3 dataOff[0] = 2jshell> "%dx%d".formatted($2.getWidth(), $2.getHeight())
$3 ==> "403x302"jshell> ImageIO.getImageReadersBySuffix("avif").next()
$4 ==> com.github.ustc_zzzz.imageio.avif.AVIFImageReader@7bb11784jshell> ImageIO.createImageInputStream(new File("horse_in_motion_yuv420_8bpc.avif")) // animated image
$5 ==> javax.imageio.stream.FileImageInputStream@34033bd0jshell> $4.setInput($5)
jshell> $4.getNumImages(true) // image count
$7 ==> 11jshell> $4.read(0) // first image
$8 ==> BufferedImage@17d99928: type = 5 ColorModel: #pixelBits = 24 numComponents = 3 color space = java.awt.color.ICC_ColorSpace@2d6d8735 transparency = 1 has alpha = false isAlphaPre = false ByteInterleavedRaster: width = 1370 height = 885 #numDataElements 3 dataOff[0] = 2jshell> $4.read(10) // last image
$9 ==> BufferedImage@1ae369b7: type = 5 ColorModel: #pixelBits = 24 numComponents = 3 color space = java.awt.color.ICC_ColorSpace@2d6d8735 transparency = 1 has alpha = false isAlphaPre = false ByteInterleavedRaster: width = 1370 height = 885 #numDataElements 3 dataOff[0] = 2jshell> $4.getImageMetadata(0) // metadata for current frame
$10 ==> com.github.ustc_zzzz.imageio.avif.AVIFImageMetadata@2b80d80fjshell> (javax.imageio.metadata.IIOMetadataNode) $10.getAsTree("ustc_zzzz_imageio_avif_image_1.0") // metadata tree
$11 ==> javax.imageio.metadata.IIOMetadataNode@28864e92jshell> (javax.imageio.metadata.IIOMetadataNode) $11.getElementsByTagName("Depth").item(0) // depth node
$12 ==> javax.imageio.metadata.IIOMetadataNode@6833ce2cjshell> $12.getUserObject() // 8-bit depth image
$13 ==> 8jshell> (javax.imageio.metadata.IIOMetadataNode) $11.getElementsByTagName("PTSInTimescales").item(0) // pts in timescales node
$14 ==> javax.imageio.metadata.IIOMetadataNode@6e3c1e69jshell> $14.getUserObject() // this image to be shown at tick 0
$15 ==> 0jshell> (javax.imageio.metadata.IIOMetadataNode) $11.getElementsByTagName("DurationInTimescales").item(0) // duration in timescales node
$16 ==> javax.imageio.metadata.IIOMetadataNode@649d209ajshell> $16.getUserObject() // this image to be shown for 1 tick
$17 ==> 1jshell> $4.getStreamMetadata() // metadata for the whole avif image
$18 ==> com.github.ustc_zzzz.imageio.avif.AVIFStreamMetadata@256216b3jshell> (javax.imageio.metadata.IIOMetadataNode) $18.getAsTree("ustc_zzzz_imageio_avif_stream_1.0") // metadata tree
$19 ==> javax.imageio.metadata.IIOMetadataNode@d7b1517jshell> (javax.imageio.metadata.IIOMetadataNode) $19.getElementsByTagName("TimeScale").item(0) // time scale node
$20 ==> javax.imageio.metadata.IIOMetadataNode@23223dd8jshell> $20.getUserObject() // the time scale is 15Hz (one tick for 1/15 second)
$21 ==> 15
```