Documentation
¶
Index ¶
- Variables
- func Encode(w io.Writer, m *SuperImage, op *EncodeOptions) error
- func ParseURL(link string) (u *url.URL, format string, err error)
- type EncodeOptions
- type FactoryOptions
- type SuperImage
- func Blur(img *SuperImage, radio int) (*SuperImage, error)
- func Decode(r io.Reader, format string) (*SuperImage, error)
- func Flip(img *SuperImage) *SuperImage
- func GetByFile(filename string) (*SuperImage, error)
- func GetByURL(link string) (*SuperImage, error)
- func Negative(img *SuperImage) *SuperImage
- func New(im image.Image, format string) *SuperImage
- func Opacity(img *SuperImage, op float64) (*SuperImage, error)
- func Reflect(img *SuperImage) *SuperImage
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidOpacity = errors.New("Opacity must be between 0 and 1.")
var ErrNegativeRadio = errors.New("Radio must be higher than 0.")
Functions ¶
func Encode ¶
func Encode(w io.Writer, m *SuperImage, op *EncodeOptions) error
Encode writes the Image m to the given writer in the specified format (png, jpg, jpeg). If op *EncodeOptions is nil, the default options used are: { Quality: 100 }.
Types ¶
type EncodeOptions ¶
type EncodeOptions struct { // Encode quality for Jpeg format: 1-100 Quality int }
type FactoryOptions ¶
type SuperImage ¶
type SuperImage struct { // Sizes of the image. Width int Height int // Image format: png, jpg, jpeg. Format string // contains filtered or unexported fields }
SuperImage is an image.Image implementation that wraps another image.Image.
func Blur ¶ added in v1.4.0
func Blur(img *SuperImage, radio int) (*SuperImage, error)
Blur blurs an image by a given radio. If the radio is negative or bigger than the image's width or height, it returns an error. Radio 0 returns the original image without any change.
References: https://relate.cs.illinois.edu/course/cs357-f15/file-version/03473f64afb954c74c02e8988f518de3eddf49a4/media/00-python-numpy/Image%20Blurring.html | http://arantxa.ii.uam.es/~jms/pfcsteleco/lecturas/20081215IreneBlasco.pdf
func Decode ¶
func Decode(r io.Reader, format string) (*SuperImage, error)
Decode decodes an image from r using the specified format (png, jpg, jpeg).
func Flip ¶
func Flip(img *SuperImage) *SuperImage
Flip inverts the image horizontally returning a new *SuperImage.
func GetByFile ¶
func GetByFile(filename string) (*SuperImage, error)
GetImageFile gets an image from a current project file.
func GetByURL ¶
func GetByURL(link string) (*SuperImage, error)
GetImageFromURL gets an image from an URL with an http GET request.
func Opacity ¶ added in v1.5.0
func Opacity(img *SuperImage, op float64) (*SuperImage, error)
func Reflect ¶
func Reflect(img *SuperImage) *SuperImage
Reflect inverts the image vertically returning a new *SuperImage.
func (*SuperImage) At ¶
func (s *SuperImage) At(x, y int) color.Color
At returns the color of the pixel at (x, y). At(Bounds().Min.X, Bounds().Min.Y) returns the upper-left pixel of the grid. At(Bounds().Max.X-1, Bounds().Max.Y-1) returns the lower-right one.
func (*SuperImage) Bounds ¶
func (s *SuperImage) Bounds() image.Rectangle
Bounds returns the domain for which At can return non-zero color. The bounds do not necessarily contain the point (0, 0).
func (*SuperImage) ColorModel ¶
func (s *SuperImage) ColorModel() color.Model
ColorModel returns the Image's color model.
func (*SuperImage) Factory ¶
func (s *SuperImage) Factory(model image.Image, op *FactoryOptions) image.Image
Factory creates a new image of the same type as the model passed as argument. The function receives a FactoryOptions struct as argument, it can be nil. Also, any field of the struct can be nil, if the field is nil the function sets an default value.
The FactoryOptions has the following fields by default:
{ YCbCrSubsampleRatio: 4, Palette: new(color.Pallete), Uniform: new(color.Color) }