Browse Source

image resizing: change jpeg default quality to 85

pull/279/head
tnextday 10 years ago
parent
commit
2e0a5533db
  1. 7
      go/images/resizing.go

7
go/images/resizing.go

@ -11,6 +11,11 @@ import (
"github.com/disintegration/imaging" "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) { func Resized(ext string, data []byte, width, height int) (resized []byte, w int, h int) {
if width == 0 && height == 0 { if width == 0 && height == 0 {
return data, 0, 0 return data, 0, 0
@ -34,7 +39,7 @@ func Resized(ext string, data []byte, width, height int) (resized []byte, w int,
case ".png": case ".png":
png.Encode(&buf, dstImage) png.Encode(&buf, dstImage)
case ".jpg", ".jpeg": case ".jpg", ".jpeg":
jpeg.Encode(&buf, dstImage, nil)
jpeg.Encode(&buf, dstImage, &jpeg.Options{Quality: defaultJpegQuality})
case ".gif": case ".gif":
gif.Encode(&buf, dstImage, nil) gif.Encode(&buf, dstImage, nil)
} }

Loading…
Cancel
Save