webp-imageio 如何编译及使用
2019独角兽企业重金招聘Python工程师标准>>>
资源下载
- webp-imageio
- libwebp-1.0.1 for linux/maxc
- libwebp-1.0.1 for windows
- CMake-3.12.4 for linux
- CMake-3.12.4 for mac
- CMake-3.12.4 for win64-x64
- CMake-3.12.4 for win32-x86
Description
Java Image I/O reader and writer for the Google WebP image format.
License
webp-imageio is distributed under the Apache Software License version 2.0.
Usage
- Add webp-imageio.jar to the classpath of your application
- Ensure libwebp-imageio.so, libwebp-imageio.dylib or webp-imageio.dll is accessible on the Java native library path (java.library.path system property)
- The WebP reader and writer can be used like any other Image I/O reader and writer.
Decoding
WebP images can be decoded using default settings as follows.
BufferedImage image = ImageIO.read(new File("input.webp"));
To customize the WebP decoder settings you need to create instances of ImageReader and WebPReadParam.
// Obtain a WebP ImageReader instance
ImageReader reader = ImageIO.getImageReadersByMIMEType("image/webp").next();// Configure decoding parameters
WebPReadParam readParam = new WebPReadParam();
readParam.setBypassFiltering(true);// Configure the input on the ImageReader
reader.setInput(new FileImageInputStream(new File("input.webp")));// Decode the image
BufferedImage image = reader.read(0, readParam);
Encoding
Encoding is done in a similar way to decoding.
You can either use the Image I/O convenience methods to encode using default settings.
// Obtain an image to encode from somewhere
BufferedImage image = ImageIO.read(new File("input.png"));// Encode it as webp using default settings
ImageIO.write(image, "webp", new File("output.webp"));
Or you can create an instance of ImageWriter and WebPWriteParam to use custom settings.
// Obtain an image to encode from somewhere
BufferedImage image = ImageIO.read(new File("input.png"));// Obtain a WebP ImageWriter instance
ImageWriter writer = ImageIO.getImageWritersByMIMEType("image/webp").next();// Configure encoding parameters
WebPWriteParam writeParam = new WebPWriteParam(writer.getLocale());
writeParam.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
writeParam.setCompressionType(p.getCompressionTypes()[WebPWriteParam.LOSSLESS_COMPRESSION]);// Configure the output on the ImageWriter
writer.setOutput(new FileImageOutputStream(new File("output.webp")));// Encode
writer.write(null, new IIOImage(image, null, null), writeParam);
Compiling
Compiling the native library for Java SE
- Install CMake 2.8 or newer. CMake can be downloaded from www.cmake.org or installed using your systems package manager.
- Create a directory called
build
in the root of the project - Open a terminal and navigate to the newly created 'build' directory
- Run
cmake ..
in the 'build' directory to generate the build scripts for your system. cmake --build .
to compile the library- The compiled library can be found under the directory
build/src/main/c
Compiling the native library for Android
- Install the Android NDK.
- Run ndk-build in the
src/android
directory - After completion
libwebp-imageio.so
can be found undersrc/android/libs/<abi>
Compiling the Java library
Using Gradle
- Run
./gradlew build -x test
in the root of the project - The compiled Java library can be found under the
build
directory
转载于:https://my.oschina.net/who7708/blog/2878444
webp-imageio 如何编译及使用相关推荐
- webp格式图片上传以及转PNG
webp格式图片上传 导入maven依赖 <!-- https://mvnrepository.com/artifact/org.sejda.imageio/webp-imageio --> ...
- 记第一次实习面试经历(字节跳动)
想要获取笔者自己整理的Android.Java面试资料原文文稿(markdown格式),可关注左边栏二维码所示公众号,公众号内回复"A3"(Android资料)."J4& ...
- 【Android 安装包优化】WebP 应用 ( libwebp 源码下载 | Android.mk 和 Application.mk 构建脚本修改 | libwebp 函数库编译 )
文章目录 一. libwebp 源码下载 二. libwebp 源码编译脚本修改 三. libwebp 函数库编译 四.参考资料 一. libwebp 源码下载 Google 提供了一系列的 WebP ...
- ImageIO.read(inputStream)读取.webp格式图片报错
0.码仙励志 莫妒他长,妒长,则己终是短.莫护己短,护短,则己终不长. 1.问题描述 今天测试提了一个新bug,查找原因是因为测试上传了一张.webp格式的图片. 在代码运行到 javax.image ...
- OSG第三方库编译之二十五:webp编译(Windows、Linux、Macos环境下编译)
目录 1.webp介绍 2.webp下载 3.Linux下编译 4.MacOS下编译 5.Windows下编译 1.webp介绍 WebP(发音:weppy)是一种提供了有损压缩与无损压缩(可逆压缩) ...
- QT+OSG/osgEarth编译之八:webp+Qt编译(一套代码、一套框架,跨平台编译,版本:libwebp-1.2.2)
目录 1.WebP介绍 2.文件下载 3.文件分析 4.pro文件 5.编译实践 1.WebP介绍
- php webp,如何编译php以启用webp支持?
虽然我多次编译php 5.5.10,但仍然无法获得webp支持启用,这由" http://cn2.php.net/manual/zh/function.imagewebp.php" ...
- Java操作Google Webp图片格式转换实践
目录 webp压缩的好处 Java使用webp代码编译 Webp开源项目 nintha/webp-imageio-core qwong/j-webp 可用的webp依赖和包 Webp 编解码 编码 解 ...
- java实现图片格式转换(svg、png、webp)
文章目录 一.svg文件 1.1 svg介绍 1.2 svg文件操作 1.2.1 获取svg文件源码 1.2.2 获取svg文件宽高 1.2.3 获取svg文件颜色 1.2.4 svg文件着色 二.s ...
最新文章
- 读Zepto源码之操作DOM
- mysql 端口time_wait_TIME_WAIT状态全是3306解决办法
- git-fork下来的项目(拷贝到本地 根据原来的库更新)
- Xshell更改命令提示符以及背景配色
- pip list和pip freeze的区别(列出所有包,列出包的requirements格式)
- linux 导入函数,共享库 – Linux ELF文件:如何获取属于导入函数的共享对象
- Common sql statement
- 现代软件工程系列 学生的精彩文章 (1)
- 鸿蒙ACE框架-使用JS调用C++(1)
- 网络协议 反扒机制 fidder 抓包工具
- Atitit org.eclipse.jdt 的ast 架构 Eclipse JDT API spec
- 视频格式转换工具,用到ws.schild.jave,之前是用的it.sauronsoftware.jave,作者已经不维护了
- 红外图像动态范围压缩和对比度增强
- 使用highEcharts做出中国地图的效果图
- Springboot+netty实现Web聊天室
- 计算机系统导论与计算机导论,计算机系统导论之学习心得
- Chrome保存整个网页为图片、PDF
- 华为笔记本linux双系统,真的有必要吗?华为笔记本搭载双系统
- 玩转OpenStack网络Neutron(1)--热身
- 入门系列之改进小波阈值降噪