add compiletime build tag 'disableimagecrush' to remove cgo dependency
This commit is contained in:
parent
f0fe3685c2
commit
5603cdd393
4
image.go
4
image.go
@ -4,8 +4,6 @@ import (
|
||||
"bytes"
|
||||
"image"
|
||||
"image/jpeg"
|
||||
|
||||
"code.ivysaur.me/imagequant"
|
||||
)
|
||||
|
||||
func (this *Thumbnailer) RenderScaledImage(src image.Image) ([]byte, error) {
|
||||
@ -60,7 +58,7 @@ func (this *Thumbnailer) RenderScaledImage(src image.Image) ([]byte, error) {
|
||||
|
||||
switch this.ofmt {
|
||||
case OUTPUT_PNG_CRUSH:
|
||||
return crush(dest, imagequant.SPEED_FASTEST)
|
||||
return crushFast(dest)
|
||||
|
||||
case OUTPUT_JPG:
|
||||
buff := bytes.Buffer{}
|
||||
|
@ -1,3 +1,5 @@
|
||||
//+build !disableimagecrush
|
||||
|
||||
package thumbnail
|
||||
|
||||
import (
|
||||
@ -51,6 +53,10 @@ func rgb8PaletteToGoImage(w, h int, rgb8data []byte, pal color.Palette) image.Im
|
||||
return ret
|
||||
}
|
||||
|
||||
func crushFast(img image.Image) ([]byte, error) {
|
||||
return crush(img, imagequant.SPEED_FASTEST)
|
||||
}
|
||||
|
||||
func crush(img image.Image, speed int) ([]byte, error) {
|
||||
|
||||
width := img.Bounds().Max.X
|
||||
|
12
imagecrush_disabled.go
Normal file
12
imagecrush_disabled.go
Normal file
@ -0,0 +1,12 @@
|
||||
// +build disableimagecrush
|
||||
|
||||
package thumbnail
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"image"
|
||||
)
|
||||
|
||||
func crushFast(img image.Image) ([]byte, error) {
|
||||
return nil, errors.New("Pngquant not compiled in")
|
||||
}
|
Loading…
Reference in New Issue
Block a user