Documentation ¶
Overview ¶
Package crop provides image crop data structures and helpers.
Copyright (c) 2018 - 2024 PhotoPrism UG. All rights reserved.
This program is free software: you can redistribute it and/or modify it under Version 3 of the GNU Affero General Public License (the "AGPL"): <https://docs.photoprism.app/license/agpl> This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. The AGPL is supplemented by our Trademark and Brand Guidelines, which describe how our Brand Assets may be used: <https://www.photoprism.app/trademark>
Feel free to send an email to hello@photoprism.app if you have questions, want to support our work, or just want to say hello.
Additional information can be found in our Developer Guide: <https://docs.photoprism.app/developer-guide/>
Index ¶
- Variables
- func FileName(hash, area string, width, height int, thumbPath string) (fileName string, err error)
- func FileWidth(area Area, size Size) int
- func FromCache(hash, area string, size Size, thumbPath string) (fileName string, err error)
- func FromRequest(hash, area string, size Size, thumbPath string) (fileName string, err error)
- func ImageFromThumb(thumbName string, area Area, size Size, cache bool) (img image.Image, err error)
- func IsCroppedThumb(thumb string) int
- func ParseThumb(thumb string) (fileHash, area string)
- func ThumbFileName(hash string, area Area, size Size, thumbPath string) (string, error)
- type Area
- func (a Area) Bottom() float64
- func (a Area) Bounds(img image.Image) (min, max image.Point, dim int)
- func (a Area) Empty() bool
- func (a Area) FileWidth(size Size) int
- func (a Area) Left() float64
- func (a Area) Overlap(other Area) (x, y float64)
- func (a Area) OverlapArea(other Area) (area float64)
- func (a Area) OverlapPercent(other Area) int
- func (a Area) Right() float64
- func (a Area) String() string
- func (a Area) Surface() float64
- func (a Area) SurfaceRatio(area float64) float64
- func (a Area) Thumb(fileHash string) string
- func (a Area) Top() float64
- type Areas
- type Name
- type Size
- type SizeMap
Constants ¶
This section is empty.
Variables ¶
var (
DefaultOptions = []thumb.ResampleOption{thumb.ResampleFillCenter, thumb.ResampleDefault}
)
var (
ErrNotFound = errors.New("not found")
)
var Sizes = SizeMap{ Tile50: {Tile50, Tile320, "Lists", 50, 50, DefaultOptions}, Tile100: {Tile100, Tile320, "Maps", 100, 100, DefaultOptions}, Tile160: {Tile160, Tile320, "FaceNet", 160, 160, DefaultOptions}, Tile224: {Tile224, Tile320, "TensorFlow, Mosaic", 224, 224, DefaultOptions}, Tile320: {Tile320, "", "UI", 320, 320, DefaultOptions}, Tile500: {Tile500, "", "FaceNet", 500, 500, DefaultOptions}, }
Sizes contains the properties of all thumbnail sizes.
Functions ¶
func FromRequest ¶
FromRequest returns the crop file name for an image hash, and creates it if needed.
func ImageFromThumb ¶
func ImageFromThumb(thumbName string, area Area, size Size, cache bool) (img image.Image, err error)
ImageFromThumb returns a cropped area from an existing thumbnail image.
func IsCroppedThumb ¶
IsCroppedThumb tests if the string represents a cropped thumbnail and returns the split position if true.
func ParseThumb ¶
ParseThumb splits a thumbnail string into the crop area and file hash.
Types ¶
type Area ¶
type Area struct { Name string `json:"name,omitempty"` X float32 `json:"x,omitempty"` Y float32 `json:"y,omitempty"` W float32 `json:"w,omitempty"` H float32 `json:"h,omitempty"` }
Area represents a relative crop area.
func (Area) OverlapArea ¶
OverlapArea calculates the overlap area of two areas.
func (Area) OverlapPercent ¶
OverlapPercent calculates the overlap ratio of two areas in percent.
func (Area) SurfaceRatio ¶
SurfaceRatio returns the surface ratio.
type Name ¶
type Name string
Name represents a crop size name.