image

package
v1.33.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 10, 2020 License: BSD-2-Clause Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrorCodeImageContentIntentUnexpected = "image-content-intent-unexpected"
	ErrorCodeImageMalformed               = "image-malformed"
)
View Source
const (
	ContentIntentAlternate      = "alternate"
	ContentIntentOriginal       = "original"
	HeightMaximum               = 10000
	HeightMinimum               = 1
	MediaTypeImageJPEG          = "image/jpeg"
	MediaTypeImagePNG           = "image/png"
	ModeDefault                 = ModeFit
	ModeFill                    = "fill"
	ModeFillDown                = "fillDown"
	ModeFit                     = "fit"
	ModeFitDown                 = "fitDown"
	ModePad                     = "pad"
	ModePadDown                 = "padDown"
	ModeScale                   = "scale"
	ModeScaleDown               = "scaleDown"
	NameLengthMaximum           = 100
	QualityDefault              = 95
	QualityMaximum              = 100
	QualityMinimum              = 1
	RenditionExtensionSeparator = "."
	RenditionFieldSeparator     = "_"
	RenditionKeyValueSeparator  = "="
	RenditionsLengthMaximum     = 10
	SizeMaximum                 = 100 * 1024 * 1024
	StatusAvailable             = "available"
	StatusCreated               = "created"
	WidthMaximum                = 10000
	WidthMinimum                = 1
)

Variables

This section is empty.

Functions

func ContentIDValidator

func ContentIDValidator(value string, errorReporter structure.ErrorReporter)

func ContentIntentValidator

func ContentIntentValidator(value string, errorReporter structure.ErrorReporter)

func ContentIntents

func ContentIntents() []string

func ErrorImageContentIntentUnexpected

func ErrorImageContentIntentUnexpected(value string) error

func ErrorImageMalformed

func ErrorImageMalformed(reason string) error

func ErrorValueRenditionNotParsable

func ErrorValueRenditionNotParsable(value string) error

func ErrorValueStringAsColorNotValid

func ErrorValueStringAsColorNotValid(value string) error

func ErrorValueStringAsContentIDNotValid

func ErrorValueStringAsContentIDNotValid(value string) error

func ErrorValueStringAsContentIntentNotValid

func ErrorValueStringAsContentIntentNotValid(value string) error

func ErrorValueStringAsIDNotValid

func ErrorValueStringAsIDNotValid(value string) error

func ErrorValueStringAsRenditionsIDNotValid

func ErrorValueStringAsRenditionsIDNotValid(value string) error

func ExtensionFromMediaType

func ExtensionFromMediaType(mediaType string) (string, bool)

func ExtensionValidator

func ExtensionValidator(value string, errorReporter structure.ErrorReporter)

func IDValidator

func IDValidator(value string, errorReporter structure.ErrorReporter)

func IsValidContentID

func IsValidContentID(value string) bool

func IsValidContentIntent

func IsValidContentIntent(value string) bool

func IsValidExtension

func IsValidExtension(value string) bool

func IsValidID

func IsValidID(value string) bool

func IsValidMediaType

func IsValidMediaType(value string) bool

func IsValidRenditionsID

func IsValidRenditionsID(value string) bool

func MediaTypeFromExtension

func MediaTypeFromExtension(extension string) (string, bool)

func MediaTypeSupportsQuality

func MediaTypeSupportsQuality(mediaType string) bool

func MediaTypeSupportsTransparency

func MediaTypeSupportsTransparency(mediaType string) bool

func MediaTypeValidator

func MediaTypeValidator(value string, errorReporter structure.ErrorReporter)

func MediaTypes

func MediaTypes() []string

func Modes

func Modes() []string

func NewContentID

func NewContentID() string

func NewID

func NewID() string

func NewRenditionsID

func NewRenditionsID() string

func NormalizeMode

func NormalizeMode(mode string) string

func RenditionsIDValidator

func RenditionsIDValidator(value string, errorReporter structure.ErrorReporter)

func Statuses

func Statuses() []string

func ValidateContentID

func ValidateContentID(value string) error

func ValidateContentIntent

func ValidateContentIntent(value string) error

func ValidateExtension

func ValidateExtension(value string) error

func ValidateID

func ValidateID(value string) error

func ValidateMediaType

func ValidateMediaType(value string) error

func ValidateRenditionsID

func ValidateRenditionsID(value string) error

Types

type Client

type Client interface {
	List(ctx context.Context, userID string, filter *Filter, pagination *page.Pagination) (ImageArray, error)
	Create(ctx context.Context, userID string, metadata *Metadata, contentIntent string, content *Content) (*Image, error)
	CreateWithMetadata(ctx context.Context, userID string, metadata *Metadata) (*Image, error)
	CreateWithContent(ctx context.Context, userID string, contentIntent string, content *Content) (*Image, error)
	DeleteAll(ctx context.Context, userID string) error

	Get(ctx context.Context, id string) (*Image, error)
	GetMetadata(ctx context.Context, id string) (*Metadata, error)
	GetContent(ctx context.Context, id string, mediaType *string) (*Content, error)
	GetRenditionContent(ctx context.Context, id string, rendition *Rendition) (*Content, error)
	PutMetadata(ctx context.Context, id string, condition *request.Condition, metadata *Metadata) (*Image, error)
	PutContent(ctx context.Context, id string, condition *request.Condition, contentIntent string, content *Content) (*Image, error)
	Delete(ctx context.Context, id string, condition *request.Condition) (bool, error)
}

type Color

type Color struct {
	color.NRGBA
}

func BackgroundDefault

func BackgroundDefault() *Color

func NewColor

func NewColor(r uint8, g uint8, b uint8, a uint8) *Color

func ParseColor

func ParseColor(value string) (*Color, error)

func (*Color) String

func (c *Color) String() string

type Content

type Content struct {
	Body      io.ReadCloser `json:"-"`
	DigestMD5 *string       `json:"digestMD5,omitempty"`
	MediaType *string       `json:"mediaType,omitempty"`
}

func NewContent

func NewContent() *Content

func (*Content) Validate

func (c *Content) Validate(validator structure.Validator)

type ContentAttributes

type ContentAttributes struct {
	DigestMD5    *string    `json:"digestMD5,omitempty" bson:"digestMD5,omitempty"`
	MediaType    *string    `json:"mediaType,omitempty" bson:"mediaType,omitempty"`
	Width        *int       `json:"width,omitempty" bson:"width,omitempty"`
	Height       *int       `json:"height,omitempty" bson:"height,omitempty"`
	Size         *int       `json:"size,omitempty" bson:"size,omitempty"`
	CreatedTime  *time.Time `json:"createdTime,omitempty" bson:"createdTime,omitempty"`
	ModifiedTime *time.Time `json:"modifiedTime,omitempty" bson:"modifiedTime,omitempty"`
}

func NewContentAttributes

func NewContentAttributes() *ContentAttributes

func ParseContentAttributes

func ParseContentAttributes(parser structure.ObjectParser) *ContentAttributes

func (*ContentAttributes) Parse

func (c *ContentAttributes) Parse(parser structure.ObjectParser)

func (*ContentAttributes) SupportsQuality

func (c *ContentAttributes) SupportsQuality() bool

func (*ContentAttributes) SupportsTransparency

func (c *ContentAttributes) SupportsTransparency() bool

func (*ContentAttributes) Validate

func (c *ContentAttributes) Validate(validator structure.Validator)

type Filter

type Filter struct {
	Status        *[]string `json:"status,omitempty"`
	ContentIntent *[]string `json:"contentIntent,omitempty"`
}

func NewFilter

func NewFilter() *Filter

func (*Filter) MutateRequest

func (f *Filter) MutateRequest(req *http.Request) error

func (*Filter) Parse

func (f *Filter) Parse(parser structure.ObjectParser)

func (*Filter) Validate

func (f *Filter) Validate(validator structure.Validator)

type Image

type Image struct {
	ID                *string            `json:"id,omitempty" bson:"id,omitempty"`
	UserID            *string            `json:"userId,omitempty" bson:"userId,omitempty"`
	Status            *string            `json:"status,omitempty" bson:"status,omitempty"`
	Metadata          *Metadata          `json:"metadata,omitempty" bson:"metadata,omitempty"`
	ContentID         *string            `json:"contentId,omitempty" bson:"contentId,omitempty"`
	ContentIntent     *string            `json:"contentIntent,omitempty" bson:"contentIntent,omitempty"`
	ContentAttributes *ContentAttributes `json:"contentAttributes,omitempty" bson:"contentAttributes,omitempty"`
	RenditionsID      *string            `json:"renditionsId,omitempty" bson:"renditionsId,omitempty"`
	Renditions        *[]string          `json:"renditions,omitempty" bson:"renditions,omitempty"`
	CreatedTime       *time.Time         `json:"createdTime,omitempty" bson:"createdTime,omitempty"`
	ModifiedTime      *time.Time         `json:"modifiedTime,omitempty" bson:"modifiedTime,omitempty"`
	DeletedTime       *time.Time         `json:"deletedTime,omitempty" bson:"deletedTime,omitempty"`
	Revision          *int               `json:"revision,omitempty" bson:"revision,omitempty"`
}

func (*Image) HasContent

func (i *Image) HasContent() bool

func (*Image) HasRendition

func (i *Image) HasRendition(rendition Rendition) bool

func (*Image) Parse

func (i *Image) Parse(parser structure.ObjectParser)

func (*Image) Sanitize

func (i *Image) Sanitize(details request.Details) error

func (*Image) Validate

func (i *Image) Validate(validator structure.Validator)

type ImageArray

type ImageArray []*Image

func (ImageArray) Sanitize

func (i ImageArray) Sanitize(details request.Details) error

type Metadata

type Metadata struct {
	Associations *association.AssociationArray `json:"associations,omitempty" bson:"associations,omitempty"`
	Location     *location.Location            `json:"location,omitempty" bson:"location,omitempty"`
	Metadata     *metadata.Metadata            `json:"metadata,omitempty" bson:"metadata,omitempty"`
	Name         *string                       `json:"name,omitempty" bson:"name,omitempty"`
	Origin       *origin.Origin                `json:"origin,omitempty" bson:"origin,omitempty"`
}

func NewMetadata

func NewMetadata() *Metadata

func ParseMetadata

func ParseMetadata(parser structure.ObjectParser) *Metadata

func (*Metadata) IsEmpty

func (m *Metadata) IsEmpty() bool

func (*Metadata) Parse

func (m *Metadata) Parse(parser structure.ObjectParser)

func (*Metadata) Validate

func (m *Metadata) Validate(validator structure.Validator)

type Rendition

type Rendition struct {
	MediaType  *string `json:"mediaType,omitempty"`
	Width      *int    `json:"width,omitempty"`
	Height     *int    `json:"height,omitempty"`
	Mode       *string `json:"mode,omitempty"`
	Background *Color  `json:"background,omitempty"`
	Quality    *int    `json:"quality,omitempty"`
}

func NewRendition

func NewRendition() *Rendition

func ParseRenditionFromString

func ParseRenditionFromString(valueString string) (*Rendition, error)

func (*Rendition) ConstrainHeight

func (r *Rendition) ConstrainHeight(aspectRatio float64)

func (*Rendition) ConstrainWidth

func (r *Rendition) ConstrainWidth(aspectRatio float64)

func (*Rendition) Parse

func (r *Rendition) Parse(parser structure.ObjectParser)

func (*Rendition) String

func (r *Rendition) String() string

func (*Rendition) SupportsQuality

func (r *Rendition) SupportsQuality() bool

func (*Rendition) SupportsTransparency

func (r *Rendition) SupportsTransparency() bool

func (*Rendition) Validate

func (r *Rendition) Validate(validator structure.Validator)

func (*Rendition) WithDefaults

func (r *Rendition) WithDefaults(aspectRatio float64) *Rendition

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL