Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Go concurrency #165

Open
AriaFantom opened this issue Mar 31, 2022 · 2 comments
Open

Go concurrency #165

AriaFantom opened this issue Mar 31, 2022 · 2 comments

Comments

@AriaFantom
Copy link

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

@dolmen
Copy link

dolmen commented May 5, 2022

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

@AriaFantom
Copy link
Author

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,
		})
	
	
	

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants