mirror of
https://github.com/mickael-kerjean/filestash.git
synced 2025-10-30 09:37:55 +08:00
maintenance (plugin): API change on the image transcoding service
This commit is contained in:
@ -13,7 +13,7 @@ func Init(config *Configuration) {
|
|||||||
plugin_enable := config.Get("feature.image.enable").Default(true).Bool()
|
plugin_enable := config.Get("feature.image.enable").Default(true).Bool()
|
||||||
plugin_thumbsize := uint(config.Get("feature.image.thumbnail_size").Default(300).Int())
|
plugin_thumbsize := uint(config.Get("feature.image.thumbnail_size").Default(300).Int())
|
||||||
|
|
||||||
Hooks.Register.ProcessFileContentBeforeSend(func(reader io.ReadCloser, ctx *App, res *http.ResponseWriter, req *http.Request) (io.Reader, error){
|
Hooks.Register.ProcessFileContentBeforeSend(func(reader io.ReadCloser, ctx *App, res *http.ResponseWriter, req *http.Request) (io.ReadCloser, error){
|
||||||
if plugin_enable == false {
|
if plugin_enable == false {
|
||||||
return reader, nil
|
return reader, nil
|
||||||
}
|
}
|
||||||
@ -36,6 +36,6 @@ func Init(config *Configuration) {
|
|||||||
img = resize.Resize(plugin_thumbsize, 0, img, resize.Lanczos3)
|
img = resize.Resize(plugin_thumbsize, 0, img, resize.Lanczos3)
|
||||||
out := bytes.NewBufferString("")
|
out := bytes.NewBufferString("")
|
||||||
jpeg.Encode(out, img, &jpeg.Options{50})
|
jpeg.Encode(out, img, &jpeg.Options{50})
|
||||||
return out, nil
|
return NewReadCloserFromReader(out), nil
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -119,7 +119,7 @@ func Init(conf *Configuration) {
|
|||||||
os.RemoveAll(cachePath)
|
os.RemoveAll(cachePath)
|
||||||
os.MkdirAll(cachePath, os.ModePerm)
|
os.MkdirAll(cachePath, os.ModePerm)
|
||||||
|
|
||||||
Hooks.Register.ProcessFileContentBeforeSend(func (reader io.ReadCloser, ctx *App, res *http.ResponseWriter, req *http.Request) (io.Reader, error){
|
Hooks.Register.ProcessFileContentBeforeSend(func (reader io.ReadCloser, ctx *App, res *http.ResponseWriter, req *http.Request) (io.ReadCloser, error){
|
||||||
if plugin_enable() == false {
|
if plugin_enable() == false {
|
||||||
return reader, nil
|
return reader, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,6 @@ package lib
|
|||||||
import "C"
|
import "C"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
. "github.com/mickael-kerjean/filestash/server/common"
|
. "github.com/mickael-kerjean/filestash/server/common"
|
||||||
"io"
|
"io"
|
||||||
"runtime"
|
"runtime"
|
||||||
@ -31,7 +30,7 @@ func init() {
|
|||||||
LIBVIPS_INSTALLED = true
|
LIBVIPS_INSTALLED = true
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateThumbnail(t *Transform) (io.Reader, error) {
|
func CreateThumbnail(t *Transform) (io.ReadCloser, error) {
|
||||||
if LIBVIPS_INSTALLED == false {
|
if LIBVIPS_INSTALLED == false {
|
||||||
return nil, NewError("Libvips not installed", 501)
|
return nil, NewError("Libvips not installed", 501)
|
||||||
}
|
}
|
||||||
@ -45,7 +44,7 @@ func CreateThumbnail(t *Transform) (io.Reader, error) {
|
|||||||
}
|
}
|
||||||
buf := C.GoBytes(buffer, C.int(len))
|
buf := C.GoBytes(buffer, C.int(len))
|
||||||
C.g_free(C.gpointer(buffer))
|
C.g_free(C.gpointer(buffer))
|
||||||
return bytes.NewReader(buf), nil
|
return NewReadCloserFromBytes(buf), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func boolToCInt(val bool) C.int {
|
func boolToCInt(val bool) C.int {
|
||||||
|
|||||||
Reference in New Issue
Block a user