转换
图像格式和类型转换操作。
函数映射
| libvips C | Dart 绑定 | Pipeline 方法 | PipelineSpec |
|---|---|---|---|
vips_crop() | apiBindings.crop() | pipeline.crop() | spec.crop() |
vips_extract_area() | apiBindings.extractArea() | - | - |
vips_smartcrop() | apiBindings.smartcrop() | pipeline.smartCrop() | spec.smartCrop() |
vips_flip() | apiBindings.flip() | pipeline.flip() | spec.flip() |
vips_embed() | apiBindings.embed() | pipeline.embed() | spec.embed() |
vips_gravity() | apiBindings.gravity() | pipeline.gravity() | spec.gravity() |
vips_zoom() | apiBindings.zoom() | pipeline.zoom() | spec.zoom() |
vips_autorot() | apiBindings.autorot() | pipeline.autoRotate() | spec.autoRotate() |
vips_cast() | conversionBindings.cast() | pipeline.cast() | spec.cast() |
vips_bandjoin() | conversionBindings.bandjoin() | - | - |
crop / extract_area
从图像中提取矩形区域。
// (left, top, width, height)
pipeline.crop(100, 100, 400, 300)
smartcrop
自动裁剪到最有趣的区域。
// (width, height)
pipeline.smartCrop(400, 300)
Interesting 选项:
VipsInteresting.none- 仅裁剪VipsInteresting.centre- 从中心裁剪VipsInteresting.attention- 聚焦有趣区域VipsInteresting.entropy- 基于熵裁剪
flip
水平或垂直翻转图像。
pipeline.flipHorizontal()
pipeline.flipVertical()
autorot
根据 EXIF 方向标签自动旋转。
pipeline.autoRotate()
embed
将图像嵌入更大的画布。
apiBindings.embed(input, output, x, y, width, height);
gravity
使用重力方向将图像放置在更大的画布中。
apiBindings.gravity(input, output, direction, width, height);
方向: VipsCompassDirection.centre, north, south, east, west 等。