Documentation ¶
Index ¶
- Constants
- type Creator
- type Info
- type Meta
- type Option
- type Service
- func (s *Service) DominantImageColor(ctx context.Context, photo *Info) (color.Color, error)
- func (s *Service) Download(ctx context.Context, info *Info) error
- func (s *Service) Photo(ctx context.Context, photoUrl string) (*Info, error)
- func (s *Service) ResizedImage(ctx context.Context, info *Info, opts ...Option) (*os.File, error)
- type Source
Constants ¶
View Source
const ( DefaultMaxWidth uint = 3840 DefaultMaxHeight uint = 3840 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Info ¶
type Info struct { // Key is a special value that is usually set. Key string // Meta is the photo metadata. *Meta // File, if not nil, holds a reference to a file handle open for reading the // image. *os.File }
Info is the information about a photo. It combines the cache key, the loaded photo metadata, and the file handle to the JPEG.
func (*Info) Close ¶
Close ensures the file handle is closed, if present. Should always be called when done with the photo info.
func (*Info) HasDownload ¶
HasPhoto returns true if the photo info has a downloaded file to work with.
type Meta ¶
type Meta struct { Link string `yaml:"link"` Type string `yaml:"type"` Title string `yaml:"title,omitempty"` Color string `yaml:"color,omitempty"` Creator }
Meta contains the metadata about a photo.
type Service ¶
func NewService ¶
func (*Service) DominantImageColor ¶
DominantImageColor returns a resized version of the photo if it is larger than the maximum width and height I have set.
type Source ¶
type Source interface { // CacheKey returns the cache key for a given URL. If the source does not // have a value for the URL, it returns false. CacheKey(url string) (string, bool) // Meta returns the photo info for a given URL. Photo(ctx context.Context, url string) (info *Info, err error) // Download downloads the photo and attaches it to the given Info. Download(ctx context.Context, info *Info) error }
Source is the interface for a source of photo information.
Click to show internal directories.
Click to hide internal directories.