From da8c9707c92e627a254f3c26011fa07cf9be28b5 Mon Sep 17 00:00:00 2001 From: Tomas Aparicio Date: Mon, 30 Mar 2015 02:49:19 +0200 Subject: [PATCH] refactor(type) --- resize_test.go | 5 +---- type.go | 9 ++------- vips.go | 8 ++++---- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/resize_test.go b/resize_test.go index 245d2fa..973aad3 100644 --- a/resize_test.go +++ b/resize_test.go @@ -2,7 +2,6 @@ package bimg import ( "io/ioutil" - "net/http" "os" "testing" ) @@ -25,9 +24,7 @@ func TestResize(t *testing.T) { t.Errorf("Resize(imgData, %#v) error: %#v", options, err) } - debug("Image %s", http.DetectContentType(newImg)) - - if http.DetectContentType(newImg) != "image/jpeg" { + if DetermineType(newImg) != JPEG { t.Fatal("Image is not jpeg") } diff --git a/type.go b/type.go index f0f6cfc..9a9cbb8 100644 --- a/type.go +++ b/type.go @@ -9,11 +9,6 @@ const ( MAGICK = "magick" ) -type Type struct { - Name string - Mime string -} - -func DetermineType(buf []byte) *Type { - return &Type{Name: "jpg", Mime: "image/jpg"} +func DetermineType(buf []byte) string { + return vipsImageType(buf) } diff --git a/vips.go b/vips.go index 81aa0b9..b464e9a 100644 --- a/vips.go +++ b/vips.go @@ -87,10 +87,6 @@ func vipsExtract(image *C.struct__VipsImage, left int, top int, width int, heigh return buf, nil } -type vipsSaveOptions struct { - Quality int -} - func vipsImageType(buf []byte) string { imageType := UNKNOWN @@ -119,6 +115,10 @@ func vipsImageType(buf []byte) string { return imageType } +type vipsSaveOptions struct { + Quality int +} + func vipsSave(image *C.struct__VipsImage, o vipsSaveOptions) ([]byte, error) { var ptr unsafe.Pointer length := C.size_t(0)