gpt4 book ai didi

govips Option struct 如何设置白色背景

转载 作者:IT王子 更新时间:2023-10-29 02:09:37 25 4
gpt4 key购买 nike

https://github.com/davidbyttow/govips 选项

// Option is a type that is passed to internal libvips functions
type Option struct {
Name string
ref interface{}
gvalue C.GValue
closer func(gv *C.GValue)
output bool
}

无法弄清楚如何添加一个选项以嵌入到 Go 中以设置白色背景

x := 100 - imgRef.Width()/2
y := 100 - imgRef.Height()/2
img, err := vips.Embed(imgRef.Image(), x, y, 200, 200, background)

我只知道看 de cli verion 是可能的,但是如何将它翻译成 Go Option 结构对我来说是个谜

$ vips embed
embed an image in a larger image
usage:
embed in out x y width height
where:
in - Input image, input VipsImage
out - Output image, output VipsImage
x - Left edge of input in output, input gint
default: 0
min: -1000000000, max: 1000000000
y - Top edge of input in output, input gint
default: 0
min: -1000000000, max: 1000000000
width - Image width in pixels, input gint
default: 1
min: 1, max: 1000000000
height - Image height in pixels, input gint
default: 1
min: 1, max: 1000000000
optional arguments:
extend - How to generate the extra pixels, input VipsExtend
default: black
allowed: black, copy, repeat, mirror, white, background
background - Colour for background pixels, input VipsArrayDouble
operation flags: sequential-unbuffered

最佳答案

x := 100 - imgRef.Width()/2
y := 100 - imgRef.Height()/2
img, err := vips.Embed(imgRef.Image(), x, y, 200, 200, vips.InputString("extend", "white"))

找到了,哈利路亚!

关于govips Option struct 如何设置白色背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51161850/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com