Rename color to rgbColor to not conflict with image/color

This commit is contained in:
DarthSim
2019-01-11 21:08:34 +06:00
parent ed795675be
commit 165ae18d87
4 changed files with 11 additions and 11 deletions

View File

@@ -817,7 +817,7 @@ func vipsSmartCrop(img **C.struct__VipsImage, width, height int) error {
return nil return nil
} }
func vipsFlatten(img **C.struct__VipsImage, bg color) error { func vipsFlatten(img **C.struct__VipsImage, bg rgbColor) error {
var tmp *C.struct__VipsImage var tmp *C.struct__VipsImage
if C.vips_flatten_go(*img, &tmp, C.double(bg.R), C.double(bg.G), C.double(bg.B)) != 0 { if C.vips_flatten_go(*img, &tmp, C.double(bg.R), C.double(bg.G), C.double(bg.B)) != 0 {

View File

@@ -98,7 +98,7 @@ var resizeTypes = map[string]resizeType{
"crop": resizeCrop, "crop": resizeCrop,
} }
type color struct{ R, G, B uint8 } type rgbColor struct{ R, G, B uint8 }
var hexColorRegex = regexp.MustCompile("^([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$") var hexColorRegex = regexp.MustCompile("^([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$")
@@ -127,7 +127,7 @@ type processingOptions struct {
Format imageType Format imageType
Quality int Quality int
Flatten bool Flatten bool
Background color Background rgbColor
Blur float32 Blur float32
Sharpen float32 Sharpen float32
@@ -197,8 +197,8 @@ func (po *processingOptions) presetUsed(name string) {
po.UsedPresets = append(po.UsedPresets, name) po.UsedPresets = append(po.UsedPresets, name)
} }
func colorFromHex(hexcolor string) (color, error) { func colorFromHex(hexcolor string) (rgbColor, error) {
c := color{} c := rgbColor{}
if !hexColorRegex.MatchString(hexcolor) { if !hexColorRegex.MatchString(hexcolor) {
return c, fmt.Errorf("Invalid hex color: %s", hexcolor) return c, fmt.Errorf("Invalid hex color: %s", hexcolor)
@@ -730,7 +730,7 @@ func defaultProcessingOptions(headers *processingHeaders) (*processingOptions, e
Enlarge: false, Enlarge: false,
Quality: conf.Quality, Quality: conf.Quality,
Format: imageTypeUnknown, Format: imageTypeUnknown,
Background: color{255, 255, 255}, Background: rgbColor{255, 255, 255},
Blur: 0, Blur: 0,
Sharpen: 0, Sharpen: 0,
Dpr: 1, Dpr: 1,

4
svg.go
View File

@@ -2,7 +2,7 @@ package main
import ( import (
"image" "image"
goColor "image/color" "image/color"
"io" "io"
) )
@@ -16,7 +16,7 @@ func init() {
return image.NewRGBA(image.Rect(0, 0, 1, 1)), nil return image.NewRGBA(image.Rect(0, 0, 1, 1)), nil
}, },
func(io.Reader) (image.Config, error) { func(io.Reader) (image.Config, error) {
return image.Config{ColorModel: goColor.RGBAModel, Width: 1, Height: 1}, nil return image.Config{ColorModel: color.RGBAModel, Width: 1, Height: 1}, nil
}, },
) )
} }

View File

@@ -9,7 +9,7 @@ package main
import ( import (
"errors" "errors"
"image" "image"
goColor "image/color" "image/color"
"io" "io"
"golang.org/x/image/riff" "golang.org/x/image/riff"
@@ -69,7 +69,7 @@ func decodeWebpConfig(r io.Reader) (image.Config, error) {
fh, err := d.DecodeFrameHeader() fh, err := d.DecodeFrameHeader()
return image.Config{ return image.Config{
ColorModel: goColor.YCbCrModel, ColorModel: color.YCbCrModel,
Width: fh.Width, Width: fh.Width,
Height: fh.Height, Height: fh.Height,
}, err }, err
@@ -96,7 +96,7 @@ func decodeWebpConfig(r io.Reader) (image.Config, error) {
heightMinusOne := uint32(buf[7]) | uint32(buf[8])<<8 | uint32(buf[9])<<16 heightMinusOne := uint32(buf[7]) | uint32(buf[8])<<8 | uint32(buf[9])<<16
return image.Config{ return image.Config{
ColorModel: goColor.NYCbCrAModel, ColorModel: color.NYCbCrAModel,
Width: int(widthMinusOne) + 1, Width: int(widthMinusOne) + 1,
Height: int(heightMinusOne) + 1, Height: int(heightMinusOne) + 1,
}, nil }, nil