all repos — honk @ d9607090ad6072f10b9d4414f271470d13aec583

my fork of honk

a bigger shrinker for uploads
Ted Unangst tedu@tedunangst.com
Sun, 27 Aug 2023 15:25:58 -0400
commit

d9607090ad6072f10b9d4414f271470d13aec583

parent

8f93de70bfd483ba9cbd65972d81877082dce00a

2 files changed, 26 insertions(+), 1 deletions(-)

jump to
M backend.gobackend.go

@@ -83,6 +83,31 @@ }

return svg, nil } +func bigshrink(data []byte) (*image.Image, error) { + if isSVG(data) { + return imageFromSVG(data) + } + cl, err := rpc.Dial("unix", backendSockname()) + if err != nil { + return nil, err + } + defer cl.Close() + var res ShrinkerResult + err = cl.Call("Shrinker.Shrink", &ShrinkerArgs{ + Buf: data, + Params: image.Params{ + LimitSize: 14200 * 4200, + MaxWidth: 2600, + MaxHeight: 2048, + MaxSize: 768 * 1024, + }, + }, &res) + if err != nil { + return nil, err + } + return res.Image, nil +} + func shrinkit(data []byte) (*image.Image, error) { if isSVG(data) { return imageFromSVG(data)
M web.goweb.go

@@ -1650,7 +1650,7 @@ io.Copy(&buf, file)

file.Close() data := buf.Bytes() var media, name string - img, err := shrinkit(data) + img, err := bigshrink(data) if err == nil { data = img.Data format := img.Format