smartcrop – github.com/muesli/smartcrop Index | Files

package smartcrop

import "github.com/muesli/smartcrop"

Package smartcrop implements a content aware image cropping library based on Jonas Wagner's smartcrop.js https://github.com/jwagner/smartcrop.js

Package smartcrop implements a content aware image cropping library based on Jonas Wagner's smartcrop.js https://github.com/jwagner/smartcrop.js

Index

Variables

var (
	// ErrInvalidDimensions gets returned when the supplied dimensions are invalid
	ErrInvalidDimensions = errors.New("Expect either a height or width")
)

Functions

func SmartCrop

func SmartCrop(img image.Image, width, height int) (image.Rectangle, error)

SmartCrop applies the smartcrop algorithms on the the given image and returns the top crop or an error if something went wrong. This is still here for legacy/backwards-compat reasons

Types

type Analyzer

type Analyzer interface {
	FindBestCrop(img image.Image, width, height int) (image.Rectangle, error)
}

Analyzer interface analyzes its struct and returns the best possible crop with the given width and height returns an error if invalid

func NewAnalyzer

func NewAnalyzer() Analyzer

NewAnalyzer returns a new analyzer with default settings

func NewAnalyzerWithCropSettings

func NewAnalyzerWithCropSettings(cropSettings CropSettings) Analyzer

NewAnalyzerWithCropSettings returns a new analyzer with the given settings

type Crop

type Crop struct {
	image.Rectangle
	Score Score
}

Crop contains results

type CropSettings

type CropSettings struct {
	InterpolationType resize.InterpolationFunction
	DebugMode         bool
	Log               *log.Logger
}

CropSettings contains options to change cropping behaviour

type Score

type Score struct {
	Detail     float64
	Saturation float64
	Skin       float64
}

Score contains values that classify matches

Source Files

debug.go smartcrop.go

Version
v0.2.0
Published
Aug 9, 2017
Platform
darwin/amd64
Imports
13 packages
Last checked
3 weeks ago

Tools for package owners.