From 2e0a5533dbe49c23acca17040a008ee7088d0e69 Mon Sep 17 00:00:00 2001 From: tnextday Date: Mon, 25 Jan 2016 16:13:51 +0800 Subject: [PATCH] image resizing: change jpeg default quality to 85 --- go/images/resizing.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/go/images/resizing.go b/go/images/resizing.go index 1f4b71fd4..d130163f9 100644 --- a/go/images/resizing.go +++ b/go/images/resizing.go @@ -11,6 +11,11 @@ import ( "github.com/disintegration/imaging" ) +const defaultJpegQuality = 85 + +// TODO resize image with vipsthumbnail +// use `/dev/shm` as memory file system + func Resized(ext string, data []byte, width, height int) (resized []byte, w int, h int) { if width == 0 && height == 0 { return data, 0, 0 @@ -34,7 +39,7 @@ func Resized(ext string, data []byte, width, height int) (resized []byte, w int, case ".png": png.Encode(&buf, dstImage) case ".jpg", ".jpeg": - jpeg.Encode(&buf, dstImage, nil) + jpeg.Encode(&buf, dstImage, &jpeg.Options{Quality: defaultJpegQuality}) case ".gif": gif.Encode(&buf, dstImage, nil) }