don't try shrinking too many images at once

This commit is contained in:
Ted Unangst 2019-11-25 21:50:51 -05:00
parent 04a82a0098
commit 0535e0af36
1 changed files with 5 additions and 0 deletions

View File

@ -23,6 +23,7 @@ import (
"os" "os"
"os/exec" "os/exec"
"humungus.tedunangst.com/r/webs/gate"
"humungus.tedunangst.com/r/webs/image" "humungus.tedunangst.com/r/webs/image"
) )
@ -38,7 +39,11 @@ type ShrinkerResult struct {
Image *image.Image Image *image.Image
} }
var shrinkgate = gate.NewLimiter(4)
func (s *Shrinker) Shrink(args *ShrinkerArgs, res *ShrinkerResult) error { func (s *Shrinker) Shrink(args *ShrinkerArgs, res *ShrinkerResult) error {
shrinkgate.Start()
defer shrinkgate.Finish()
img, err := image.Vacuum(bytes.NewReader(args.Buf), args.Params) img, err := image.Vacuum(bytes.NewReader(args.Buf), args.Params)
if err != nil { if err != nil {
return err return err