Documentation
¶
Index ¶
Constants ¶
const ( JpegQuality int = 85 BlurLongSide int = 32 // long side in pixels for blur/placeholder image )
const MaxReprocessRetries int = 5
Variables ¶
This section is empty.
Functions ¶
func ParseObjectKey ¶
ParseObjectKey is a helper which parses the object key from the webhook to extract the directory, file name, file extension, and slug. Exists to abstract away this logic from the main processing loop.
Types ¶
type Exif ¶
type Exif struct {
// best effort -> tries DateTimeOriginal, DateTimeDigitized, DateTime.
TakenAt *time.Time `json:"taken_at,omitempty"`
// pixel dimensions
Width int `json:"width,omitempty"`
Height int `json:"height,omitempty"`
// rotation in degrees
// 0, 90, 180, 270
// 0 means no rotation
Rotation int `json:"rotation,omitempty"`
// optional GPS coordinates -> not often present in images
Latitude *float64 `json:"latitude,omitempty"`
Longitude *float64 `json:"longitude,omitempty"`
}
Exif represents a subset of the EXIF metadata extracted from an image/picture.
type ImagePipline ¶
type ImagePipline interface {
// UploadQueue processes images submitted to the pipeline queue, parsing the webhook,
// reading the exif data if it exists, generating thumbnails, and moving the image to the correct
// directory in object storage, typically based on the image year date.
UploadQueue()
// ReprocessQueue reprocesses images in the pipeline queue, based on the ReprocessCmd instructions/criteria.
// It is primarily used for reprocessing images that may have failed initial processing, such as images
// that were uploaded without exif data and landed in staging. It is also called in order to generate any
// missing image resolutions or tile resolutions that errored upon initial processing.
ReprocessQueue()
}
ImagePipline provides methods for processing image files submitted to the pipeline.
func NewImagePipeline ¶
func NewImagePipeline( up chan storage.WebhookPutObject, re chan ReprocessCmd, wg *sync.WaitGroup, db *sql.DB, i data.Indexer, c data.Cryptor, o storage.ObjectStorage, ) ImagePipline
NewImagePipeline creates a new instance of ImageProcessor, returning a pointer to the concrete implementation.
type Repository ¶
type Repository interface {
// FindAllAlbums retrieves all album records from the database.
FindAllAlbums() ([]api.AlbumRecord, error)
// FindImageBySlugIndex retrieves an image record by its slug index.
FindImage(slugIndex string) (*api.ImageRecord, error)
// FindImageAlbums retrieves all albums associated with a given image's uuid.
FindImageAlbums(imageId string) ([]api.AlbumRecord, error)
// InsertAlbum inserts a new album metadata record into the database.
InsertAlbum(record api.AlbumRecord) error
// InsertAlbumImageXref inserts a xref record into the ablum_image table in the database.
InsertAlbumImageXref(xref api.AlbumImageXref) error
// UpdateImage updates an existing image metadata record in the database.
// Note: fields must be encrypted prior to calling this function.
UpdateImage(record api.ImageRecord) error
}
Repository is an interface for data operations related to image processing in the image processing pipeline.
func NewRepository ¶
func NewRepository(db *sql.DB) Repository
NewRepository creates a new Repository instance, returning a pointer to the concrete implementation.
type ReprocessCmd ¶
type ReprocessCmd struct {
Id string
FileName string
FileType string
Slug string
CurrentObjKey string
UpdatedObjKey string
MoveRequired bool
RetryCount int
}
ReprocessCmd represents a request to re-process an existing picture. For example, an image has its date updated or added if missing which requires it to be moved to a new year-based directory in object storage.