all repos — honk @ 39802abc538257337bf674dea6c2b9a71a5e0140

my fork of honk

combine common shrink code
Ted Unangst tedu@tedunangst.com
Thu, 16 Nov 2023 23:42:47 -0500
commit

39802abc538257337bf674dea6c2b9a71a5e0140

parent

e7b7f4eba9faafc8afaaa9c1b47470941f3dac55

1 files changed, 18 insertions(+), 24 deletions(-)

jump to
M backend.gobackend.go

@@ -90,7 +90,7 @@ }

return svg, nil } -func bigshrink(data []byte) (*image.Image, error) { +func callshrink(data []byte, params image.Params) (*image.Image, error) { if isSVG(data) { return imageFromSVG(data) }

@@ -101,13 +101,8 @@ }

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, - }, + Buf: data, + Params: params, }, &res) if err != nil { return nil, err

@@ -115,24 +110,23 @@ }

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