文档链接
- 官方文档
https://jcupitt.github.io/libvips/ - command 命令说明
https://jcupitt.github.io/libvips/API/current/using-cli.html - function 列表
https://jcupitt.github.io/libvips/API/current/func-list.html#function-list - c 的说明
https://jcupitt.github.io/libvips/API/current/using-from-c.html
函数类别说明
一般我们用到这个库时都是想转换图像,但是转化图像又分两种情况,按照文档中使用的单词:
conversion — convert images in some way: change band format, change header, insert, extract, join
resample — resample images in various ways
通俗但不准确的说就是前者只是像素的值的位置的交换,而后者则是会做一些根据现有的像素计算新的像素值(插值一类)的事情。
所以,
裁剪,嵌入,组合 就属于前者;
而对图像缩放就属于后者。
另外两类会用到的函数:
command
# 列出所有commands
$ vips -l
# 列出某个command 的参数,只要输入空参数就可以了,如:
$ vips thumbnail
# 注意参数类型有两种,other arguments 的使用要这样:
vips thumbnail 1.jpg 2.jpg 100 --height=200 --size=force
# 这些参数是可以和C 的函数对应起来的
# 使用 vips thumbnail 列出可以用参数时,同时会看的default value和allow value
# 数组参数
$ vips affine k2.jpg x.jpg "2 0 0 1"
# []
vips affine k2.jpg x.jpg[Q=90,strip] "2 0 0 1"
# 用.v 文件存储中间结果
$ vips invert input.jpg t1.v
$ vips affine t1.v output.jpg "2 0 0 1"
$ rm t1.v
# 一些extra option,比如 --vips-progress 可以显示处理的进度
vips thumbnail 1.jpg 3.jpg 500 --height=800 --crop