diff --git a/controller/color_controller.go b/controller/color_controller.go index 64cfc50..20e2e9a 100644 --- a/controller/color_controller.go +++ b/controller/color_controller.go @@ -3,7 +3,6 @@ package controller import ( "bytes" "github.com/cenkalti/dominantcolor" - "github.com/zembrodt/music-display-api/model" "image" _ "image/jpeg" _ "image/png" @@ -15,10 +14,7 @@ import ( const ( pathColor = "/color" - - urlKey = "url" - - barCodeColorThreshold = 186 + urlKey = "url" ) func validDomains() map[string]bool { @@ -39,8 +35,6 @@ func (c *MusicAPIController) getDominateColor(w http.ResponseWriter, r *http.Req } encodedUrl := urls[0] - // TODO: get image from url - coverArtUrlRaw, err := url.QueryUnescape(encodedUrl) if err != nil { respondWithError(w, http.StatusBadRequest, "Unable to unescape the provided cover art url: " + err.Error()) @@ -82,16 +76,6 @@ func (c *MusicAPIController) getDominateColor(w http.ResponseWriter, r *http.Req return } - // Get dominant color of the album art - var colorResponse model.ColorResponse - rgb := dominantcolor.Find(img) - colorResponse.Color = dominantcolor.Hex(rgb) - // See https://stackoverflow.com/questions/3942878/how-to-decide-font-color-in-white-or-black-depending-on-background-color - if float32(rgb.R) * 0.299 + float32(rgb.G) * 0.587 + float32(rgb.B) * 0.114 > barCodeColorThreshold { - colorResponse.BarCodeColor = "black" - } else { - colorResponse.BarCodeColor = "white" - } - - respondWithJSON(w, http.StatusOK, colorResponse) + // Return dominant color of the album art + respondWithJSON(w, http.StatusOK, dominantcolor.Hex(dominantcolor.Find(img))) } diff --git a/model/color_models.go b/model/color_models.go deleted file mode 100644 index 6eccd67..0000000 --- a/model/color_models.go +++ /dev/null @@ -1,6 +0,0 @@ -package model - -type ColorResponse struct { - Color string `json:"color" example:"#1500ff"` - BarCodeColor string `json:"barCodeColor" example:"white,black"` -} diff --git a/properties.go b/properties.go index a3f0a21..7520e70 100644 --- a/properties.go +++ b/properties.go @@ -2,6 +2,6 @@ package musicapi const ( Name = "Music Display API" - Version = "0.0.2" + Version = "0.1.0" APIRoot = "/api" )