gg icon indicating copy to clipboard operation
gg copied to clipboard

Go concurrency

Open AriaFantom opened this issue 3 years ago • 2 comments

Is there any way to use go concurrency if it is there can anyone please provide and example, or else the image processing take 300ms+ to load i wanna make it fast with concurrency

AriaFantom avatar Mar 31 '22 13:03 AriaFantom

Please provide example code that would allow maintainers to reproduce your issue.

dolmen avatar May 05 '22 07:05 dolmen

Please provide example code that would allow maintainers to reproduce your issue.

I wanted an example of how can i use go concurrency if you want my code then

func admit(c *gin.Context) {

		var admit Admit
		c.BindJSON(&admit)
		im, err := gg.LoadImage("card.jpg")
		if err != nil {
			log.Fatal(err)
		}
		width := im.Bounds().Max.X
		height := im.Bounds().Max.Y
		dc := gg.NewContext(width, height)
		dc.SetRGB(0, 0, 0)
		dc.DrawImage(im, 0, 0)
		dc.SetRGB(1, 1, 1)
		dc.LoadFontFace("Roboto-Regular.ttf", 16)
		dc.SetHexColor("#542A18")
		dc.DrawString(admit.Username, 105, 493)
		dc.DrawString(admit.Date, 190, 634)
		var buf bytes.Buffer
		dc.EncodePNG(&buf)
		img := base64.StdEncoding.EncodeToString(buf.Bytes())
		c.JSON(200, gin.H{
			"image": img,
		})
	
	
	

}

AriaFantom avatar May 24 '22 21:05 AriaFantom