草庐IT

image-generation

全部标签

go - go :generate directives? 有解析器吗

好像是标准doc包未解析go:generate评论。知道如何获得这些评论吗? 最佳答案 包裹go/parser在标准库中为您提供一个ast.Package值,表示单个包的抽象语法树。这棵树包括ast.Comment节点,您可以通过它们的Text字段轻松访问其文本内容。编辑:DewyBrotocontributed:一个更直接的选择是调用go/scanner包并将ScanComments标志设置为true。无需构建AST来查找评论 关于go-go:generatedirectives?有解

image - Golang Websocket 检测文件消息并在超过 1 个 ws 帧字节时写入

我需要将每张新图片保存在一个文件中,该文件由多个框架通过websockets发送。这是我的文件的代码:packagemainimport("fmt""golang.org/x/net/websocket""log""net/http""os""time")var(dirPathstringtestbytelenFileint)funccheck(eerror){ife!=nil{panic(e)}}funcChatServer(ws*websocket.Conn){deferws.Close()vartest[]bytevarpayload[]bytefor{err:=websocke

json - Golang : Protobuff generated Struct is not decoding child attribute for json. 解码

我有一个结构体正在与protobuff序列化器一起使用并且运行良好。这个结构是由protobuff生成的,因此它有很多方法,比如Unmarshal等。typeFlightstruct{FlightNostring`json:"flightno,omitempty"`Carrierstring`json:"carrier,omitempty"`}func(m*Flight)Unmarshal(data[]byte)error{l:=len(data)iNdEx:=0foriNdEx=64{returnErrIntOverflowFlight}ifiNdEx>=l{returnio.Err

Golang : How to convert an image. 图像到 uint16

我正在尝试将go-skeltrack库与我拥有的一些深度图像一起使用(不使用freenect)。为此,我需要通过自己替换kinect图像来修改提供的示例。为此,我必须读取图像并将其稍后转换为[]uint16变量。我试过的代码是:file,err:=os.Open("./images/4.png")iferr!=nil{fmt.Println("4.pngfilenotfound!")os.Exit(1)}deferfile.Close()fileInfo,_:=file.Stat()varsizeint64=fileInfo.Size()bytes:=make([]byte,size)

image - PNG 编码产生损坏的图像

我正在使用golang从视频游戏控制台读取帧缓冲区-缓冲区的格式为BRGA(然后我将其转换为RGBA)。当我将信息传递到GoPNG编码器时,输出的图像无效。我使用的代码是-哪里:wheredataisasliceofRGBApixels-0x398000inlength,pitchis5120,widthis1270,andheightis720)img:=&image.RGBA{Pix:data,Stride:pitch,Rect:image.Rect(0,0,width,height),}os.Remove("./img.png")file,_:=os.Create("./img.

image - 改变单个像素的颜色——Golang图像

我想打开jpeg图像文件,对其进行编码,更改一些像素颜色,然后按原样保存。我想做这样的事情imgfile,err:=os.Open("unchanged.jpeg")deferimgfile.Close()iferr!=nil{fmt.Println(err.Error())}img,err:=jpeg.Decode(imgfile)iferr!=nil{fmt.Println(err.Error())}img.Set(0,0,color.RGBA{85,165,34,1})img.Set(1,0,....)outFile,_:=os.Create("changed.jpeg")def

image - 在Golang中合并两张图片

在过去的15小时里,我一直在努力尝试合并piture,以便它可以具有与nametest相同的方面我的尝试在golang中,我通过创建更大的图片并将较小的图片并排粘贴成功地合并了两张图片src1,err:=imaging.Open("public/images/g8.jpg")iferr!=nil{log.Fatalf("Openfailed:%v",err)}else{}src2,err:=imaging.Open("public/images/f2.jpg")iferr!=nil{log.Fatalf("Openfailed:%v",err)}else{dstImage1:=imag

image - 无效的 JPEG 格式 : missing SOI marker

尝试解码图像并写入文件。这是我的代码:packagemainimport("bytes""fmt""github.com/reteps/gopowerschool""image/jpeg")funcmain(){client:=gopowerschool.Client("https://example.com")session,userID,err:=client.CreateUserSessionAndStudent("username","password")iferr!=nil{panic(err)}response,err:=client.GetStudentPhoto(&go

go - protoc 命令不适用于 go generate

我有以下.proto文件:$GOPATH/src/github.com/path/to/package/myPkg.proto前几行:syntax="proto3";packagemyPkg;optiongo_package="github.com/path/to/package";然后我正在创建一个包含以下内容的.go文件//go:generateprotoc-I$GOPATH/src/github.com/path/to/package--go_out=plugins=grpc:$GOPATH/srcmyPkg.protopackagesomeRandomGoPackage当从ba

image - Golang 图像 iptc 元数据

我需要从服务器上上传的文件中获取元数据,尤其是iptc元数据。我找到了两个可以导入的包,但它们都需要“libiptcdata”库。这应该不是问题,但是在我用brew安装了libary之后,因为它写在两个包页面上,并输入goget“https://github.com/Melraidin/iptc”(例如,我想使用的两个包之一),我收到以下错误:../../github.com/Melraidin/iptc/main.go:10:10:fatalerror:libiptcdata/iptc-data.h:Nosuchfileordirectory#include^~~~~~~~~~~~~