optional_outputs

command
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 24, 2025 License: MIT Imports: 5 Imported by: 0

README

VIPS Optional Outputs Examples

This example demonstrates how to capture optional output parameters from various VIPS operations. These optional outputs provide valuable information about the operations performed, such as transformation parameters, attention coordinates, and position data.

Examples

Smartcrop with Attention Coordinates

Operation: vips_smartcrop
Optional Outputs: AttentionX, AttentionY

options := vips.DefaultSmartcropOptions()
err := img.Smartcrop(width, height, options)

// Access the attention coordinates
fmt.Printf("Attention Center: x=%d, y=%d\n", options.AttentionX, options.AttentionY)

What it shows: The coordinates where the algorithm detected the most interesting content for cropping.

Mosaic with Transformation Parameters

Operation: vips_mosaic
Optional Outputs: Dx0, Dy0, Scale1, Angle1, Dx1, Dy1

options := vips.DefaultMosaicOptions()
err := img1.Mosaic(img2, direction, xref, yref, xsec, ysec, options)

// Access transformation parameters
fmt.Printf("Integer Offset: dx0=%d, dy0=%d\n", options.Dx0, options.Dy0)
fmt.Printf("Detected Scale: %.3f\n", options.Scale1)
fmt.Printf("Detected Rotation: %.3f degrees\n", options.Angle1)

What it shows: The detected transformation parameters when combining two images.

Max/Min with Position Coordinates

Operations: vips_max, vips_min
Optional Outputs: X, Y

maxOptions := vips.DefaultMaxOptions()
maxValue, err := img.Max(maxOptions)

// Access position of maximum value
fmt.Printf("Maximum value: %.2f at position x=%d, y=%d\n", 
    maxValue, maxOptions.X, maxOptions.Y)

What it shows: The coordinates where the maximum or minimum pixel values are located.

Draw Flood with Affected Area

Operation: vips_draw_flood
Optional Outputs: Left, Top, Width, Height

options := vips.DefaultDrawFloodOptions()
err := img.DrawFlood(color, x, y, options)

// Access affected area bounds
fmt.Printf("Affected area: left=%d, top=%d, width=%d, height=%d\n",
    options.Left, options.Top, options.Width, options.Height)

What it shows: The bounding box of the area affected by the flood fill operation.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL