mirror of
https://github.com/talgo-cloud/bimg.git
synced 2026-03-17 11:16:34 -07:00
refactor(type)
This commit is contained in:
parent
5e47888d78
commit
da8c9707c9
3 changed files with 7 additions and 15 deletions
|
|
@ -2,7 +2,6 @@ package bimg
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
@ -25,9 +24,7 @@ func TestResize(t *testing.T) {
|
||||||
t.Errorf("Resize(imgData, %#v) error: %#v", options, err)
|
t.Errorf("Resize(imgData, %#v) error: %#v", options, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
debug("Image %s", http.DetectContentType(newImg))
|
if DetermineType(newImg) != JPEG {
|
||||||
|
|
||||||
if http.DetectContentType(newImg) != "image/jpeg" {
|
|
||||||
t.Fatal("Image is not jpeg")
|
t.Fatal("Image is not jpeg")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
9
type.go
9
type.go
|
|
@ -9,11 +9,6 @@ const (
|
||||||
MAGICK = "magick"
|
MAGICK = "magick"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Type struct {
|
func DetermineType(buf []byte) string {
|
||||||
Name string
|
return vipsImageType(buf)
|
||||||
Mime string
|
|
||||||
}
|
|
||||||
|
|
||||||
func DetermineType(buf []byte) *Type {
|
|
||||||
return &Type{Name: "jpg", Mime: "image/jpg"}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
8
vips.go
8
vips.go
|
|
@ -87,10 +87,6 @@ func vipsExtract(image *C.struct__VipsImage, left int, top int, width int, heigh
|
||||||
return buf, nil
|
return buf, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type vipsSaveOptions struct {
|
|
||||||
Quality int
|
|
||||||
}
|
|
||||||
|
|
||||||
func vipsImageType(buf []byte) string {
|
func vipsImageType(buf []byte) string {
|
||||||
imageType := UNKNOWN
|
imageType := UNKNOWN
|
||||||
|
|
||||||
|
|
@ -119,6 +115,10 @@ func vipsImageType(buf []byte) string {
|
||||||
return imageType
|
return imageType
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type vipsSaveOptions struct {
|
||||||
|
Quality int
|
||||||
|
}
|
||||||
|
|
||||||
func vipsSave(image *C.struct__VipsImage, o vipsSaveOptions) ([]byte, error) {
|
func vipsSave(image *C.struct__VipsImage, o vipsSaveOptions) ([]byte, error) {
|
||||||
var ptr unsafe.Pointer
|
var ptr unsafe.Pointer
|
||||||
length := C.size_t(0)
|
length := C.size_t(0)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue