CollageCreator

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2022 License: LGPL-3.0 Imports: 19 Imported by: 0

README

CollageCreator

CollageCreator is a Go-language library for the automatic generation of image collages.

Library design

As a library, CollageCreator is designed to be extensible by third parties. Its workflow separates the process of collage creation into four distinct steps -- reading input images, preprocessing, collage layout, and output rendering -- and a custom implementation may be substituted for any of these steps via the API.

Provided implementations

The core library provides the following implementations for each step:

  • Input image reading via Go's built-in image library.

  • Preprocessing via a command-line switch that lets the user provide an ImageMagick-like geometry string specifying how images are to be scaled and cropped.

  • Collage layout via one of two algorithms:

    • Random placement: Images are placed at random and then adjusted to leave each image equidistant from its nearest neighbor. A binary search algorithm is used to minimize the total canvas area.

    • Tile in order: Images are placed in rows of identical width, images being scaled down to fit. An optimization algorithm is used to find a canvas size that minimizes (1) deviation from the provided aspect ratio; (2) empty space in the last row or column; and (3) the amount by which any image must be scaled down.

  • Output rendering as:

    • A PNG, JPEG, or TIFF raster image.

    • A Scalable Vector Graphics (SVG) file, using links to reference each input image file.

    • A shell script that runs ImageMagick tools to build the collage image.

Dependencies

For raster image output, CollageCreator depends on Jan Schlicht's "resize" package for image scaling.

When the sh output file type is selected, the output shell scripts require the ImageMagick command-line tools to run.

Known deficiencies

As the built-in Go image library does not read Exif metadata, CollageCreator does not take Exif orientation into account when reading images. All images read using this library must be physically rotated before input to ensure correct operation.

Documentation

Overview

This package provides an extensible framework for automatically generating image collages.

(C) 2021 August Schwerdfeger

This file contains auxiliary methods that run an interactive "balancing" algorithm over an existing image layout, putting each image in the center of the rectangle of blank space surrounding it.

Index

Constants

View Source
const (
	Uniform_Cropping   string = "Uniform_Cropping"
	Uniform_Scaling    string = "Uniform_Scaling"
	Uniform_ScaleToMin string = "Uniform_ScaleToMin"
)
View Source
const (
	Random_SeedNumber               string = "Random_SeedNumber"
	Random_MaxLayoutTries           string = "Random_MaxLayoutTries"
	Random_MaxTriesPerImage         string = "Random_MaxTriesPerImage"
	Random_SizeToleranceFactor      string = "Random_SizeToleranceFactor"
	Balancer_MaxBalanceIterations   string = "Balancer_MaxBalanceIterations"
	Balancer_BalanceToleranceFactor string = "Balancer_BalanceToleranceFactor"
)
View Source
const (
	TileInOrder_ExactOrder string = "TileInOrder_ExactOrder"
	TileInOrder_Columns    string = "TileInOrder_Columns"
)
View Source
const (
	Raster_PreloadImages string = "Raster_PreloadImages"
)

Variables

This section is empty.

Functions

func CreateCollage

func CreateCollage(parameters *Parameters) int

Runs the complete collage-creation process from reading input files to producing the output file; returns 0 if successful and nonzero if not.

func PaddingIsRelative

func PaddingIsRelative(iLay ImageLayout, img ImageIdentifier) bool

Determines whether the padding to be maintained around the given image is in relative or absolute units.

Types

type CollageCreatorComponent

type CollageCreatorComponent interface {
	// Adds information to 'parameters' about any custom parameters accepted by this object.
	RegisterCustomParameters(parameters *Parameters) bool
	// Parses, using Go's 'flag' library, any custom parameters in 'parameters' accepted by this object.
	ParseCustomParameters(parameters *Parameters) bool
}

A superinterface for any object that adds custom parameters to the CollageCreator CLI.

type CollageRenderer

type CollageRenderer interface {
	CollageCreatorComponent
	// Takes 'imageLayout' after it has been through a 'PositionCalculator' and produces an object
	// ready to write to output file(s), or error on failure.
	CreateCollageImage(imageLayout ImageLayout) (oi OutputImage, err error)
}

A superinterface for any object that renders a finished image layout to a ready-to-write output image.

type CollageRenderer_ImageMagickScript

type CollageRenderer_ImageMagickScript struct{}

Produces output in the form of a Bash script that, when run, will call ImageMagick to produce the output collage.

func CollageRenderer_ImageMagickScript_Init

func CollageRenderer_ImageMagickScript_Init() CollageRenderer_ImageMagickScript

func (CollageRenderer_ImageMagickScript) CreateCollageImage

func (icr CollageRenderer_ImageMagickScript) CreateCollageImage(imageLayout ImageLayout) (oi OutputImage, err error)

func (CollageRenderer_ImageMagickScript) ParseCustomParameters

func (ict CollageRenderer_ImageMagickScript) ParseCustomParameters(parameters *Parameters) bool

func (CollageRenderer_ImageMagickScript) RegisterCustomParameters

func (icr CollageRenderer_ImageMagickScript) RegisterCustomParameters(parameters *Parameters) bool

type CollageRenderer_Raster

type CollageRenderer_Raster struct{}

Produces output in the form of a JPEG, PNG, or TIFF file, using Jan Schlicht's "resize" package to handle scaling.

func CollageRenderer_Raster_Init

func CollageRenderer_Raster_Init() CollageRenderer_Raster

func (CollageRenderer_Raster) CreateCollageImage

func (icr CollageRenderer_Raster) CreateCollageImage(imageLayout ImageLayout) (oi OutputImage, err error)

func (CollageRenderer_Raster) ParseCustomParameters

func (ict CollageRenderer_Raster) ParseCustomParameters(parameters *Parameters) bool

func (CollageRenderer_Raster) RegisterCustomParameters

func (icr CollageRenderer_Raster) RegisterCustomParameters(parameters *Parameters) bool

type CollageRenderer_SVG

type CollageRenderer_SVG struct{}

Produces output in the form of an SVG file that links to all the input images.

func CollageRenderer_SVG_Init

func CollageRenderer_SVG_Init() CollageRenderer_SVG

func (CollageRenderer_SVG) CreateCollageImage

func (icr CollageRenderer_SVG) CreateCollageImage(imageLayout ImageLayout) (oi OutputImage, err error)

func (CollageRenderer_SVG) ParseCustomParameters

func (ict CollageRenderer_SVG) ParseCustomParameters(parameters *Parameters) bool

func (CollageRenderer_SVG) RegisterCustomParameters

func (icr CollageRenderer_SVG) RegisterCustomParameters(parameters *Parameters) bool

type CustomParameters

type CustomParameters map[string]interface{}

A map holding "custom" parameters specific to one component.

type DimensionInitializer

type DimensionInitializer interface {
	CollageCreatorComponent
	// Initialize the dimensions of each image in 'imageLayout'. Returns error on failure,
	// or 'il' on success, which may be, but is not guaranteed to be, a separate object
	// from 'imageLayout'.
	InitializeDimensions(imageLayout ImageLayout) (il ImageLayout, err error)
}

A superinterface for any object that initializes crop and scale settings for each input image before positioning starts (e.g., by scaling each image to a uniform size).

type DimensionInitializer_Original

type DimensionInitializer_Original struct{}

The simplest 'DimensionInitializer': sends all images through as-is.

func (DimensionInitializer_Original) InitializeDimensions

func (dio DimensionInitializer_Original) InitializeDimensions(imageLayout ImageLayout) (il ImageLayout, err error)

func (DimensionInitializer_Original) ParseCustomParameters

func (dio DimensionInitializer_Original) ParseCustomParameters(parameters *Parameters) bool

func (DimensionInitializer_Original) RegisterCustomParameters

func (dio DimensionInitializer_Original) RegisterCustomParameters(parameters *Parameters) bool

type DimensionInitializer_Uniform

type DimensionInitializer_Uniform struct {
	// contains filtered or unexported fields
}

A 'DimensionInitializer' that applies uniform cropping and scaling rules, specified as ImageMagick geometry strings, to all input images.

func DimensionInitializer_Uniform_Init

func DimensionInitializer_Uniform_Init() DimensionInitializer_Uniform

func (DimensionInitializer_Uniform) InitializeDimensions

func (dio DimensionInitializer_Uniform) InitializeDimensions(imageLayout ImageLayout) (il ImageLayout, err error)

func (DimensionInitializer_Uniform) ParseCustomParameters

func (dio DimensionInitializer_Uniform) ParseCustomParameters(parameters *Parameters) bool

func (DimensionInitializer_Uniform) RegisterCustomParameters

func (dio DimensionInitializer_Uniform) RegisterCustomParameters(parameters *Parameters) bool

type DimensionInitializer_Uniform_CustomParameters

type DimensionInitializer_Uniform_CustomParameters struct {
	// contains filtered or unexported fields
}

type DimensionInitializer_Uniform_ScaleToMinParameter

type DimensionInitializer_Uniform_ScaleToMinParameter struct {
	// contains filtered or unexported fields
}

type Dims

type Dims struct {
	// contains filtered or unexported fields
}

Holds a pair of floats representing dimensions or coordinates.

func MustParseDims

func MustParseDims(arg string) Dims

A front-end to 'ParseDims' that logs a fatal error if the string does not parse.

func NewDims

func NewDims(x, y float64) Dims

Creates a new 'Dims' object.

func Overlap

func Overlap(iLay ImageLayout, img1, img2 ImageIdentifier) Dims

func Padding

func Padding(iLay ImageLayout, img ImageIdentifier) Dims

Calculates the padding to be maintained around the given image.

func ParseDims

func ParseDims(arg string) (d Dims, err error)

Parses a string into a 'Dims' object. The string must consist of either one non-negative integer, or two non-negative integers separated by a comma or 'x'. Returns the parsed object, and an error if the string is malformed.

func ScaleAndCrop

func ScaleAndCrop(original Dims, cropping Geometry, scaling Geometry) Dims

Apply both the 'Scale' and 'Crop' methods to a given image, in that order.

func (Dims) Dim

func (d Dims) Dim(i int) float64

Gets the coordinate in a 'Dims' object indicated by the parameter: X if even, Y if odd.

func (*Dims) SetDim

func (d *Dims) SetDim(i int, val float64)

Sets the coordinate in a 'Dims' object indicated by the parameter: X if even, Y if odd.

func (*Dims) SetX

func (d *Dims) SetX(val float64)

Sets the X coordinate in a 'Dims' object.

func (*Dims) SetY

func (d *Dims) SetY(val float64)

Sets the Y coordinate in a 'Dims' object.

func (Dims) X

func (d Dims) X() float64

Gets the X coordinate from a 'Dims' object.

func (Dims) Y

func (d Dims) Y() float64

Gets the Y coordinate from a 'Dims' object.

type Geometry

type Geometry struct {
	// contains filtered or unexported fields
}

Represents the geometry of an image operation such as cropping or scaling, as parsed from an ImageMagick-like "geometry" string.

func EmptyGeometry

func EmptyGeometry() Geometry

Generates an "empty" 'Geometry' object in which all numeric values are 'NaN'.

func MustParseGeometry

func MustParseGeometry(arg string) Geometry

A front-end to 'ParseGeometry' that logs a fatal error if the string does not parse.

func ParseGeometry

func ParseGeometry(arg string) (geom Geometry, err error)

Parses a string into a 'Geometry' object. The string must follow the format of an ImageMagick 'geometry' parameter. Returns the parsed object, and an error if the string is malformed.

func (Geometry) Crop

func (geom Geometry) Crop(fullSize Dims) Dims

Calculate the size of an image cropped using this 'Geometry' object, relative to an image of the given size. 'fullSize' is taken into account only when the 'Percent' relative units are used.

func (Geometry) HasHeight

func (geom Geometry) HasHeight() bool

Returns true if this 'Geometry' object explicitly specifies a height.

func (Geometry) HasOffset

func (geom Geometry) HasOffset() bool

Returns true if this 'Geometry' object explicitly specifies either a horizontal or a vertical offset.

func (Geometry) HasSize

func (geom Geometry) HasSize() bool

Returns true if this 'Geometry' object explicitly specifies either a width or a height.

func (Geometry) HasWidth

func (geom Geometry) HasWidth() bool

Returns true if this 'Geometry' object explicitly specifies a width.

func (Geometry) HasX

func (geom Geometry) HasX() bool

Returns true if this 'Geometry' object explicitly specifies a horizontal offset.

func (Geometry) HasY

func (geom Geometry) HasY() bool

Returns true if this 'Geometry' object explicitly specifies a vertical offset.

func (Geometry) Offset

func (geom Geometry) Offset(fullSize Dims) Dims

Calculate the offset of this 'Geometry' object relative to an image of the given size. 'fullSize' is taken into account only when the 'Percent' relative units are used.

func (Geometry) PreserveAspectRatio

func (geom Geometry) PreserveAspectRatio() bool

Returns true if this 'Geometry' object specifies preservation of the aspect ratio.

func (Geometry) Scale

func (geom Geometry) Scale(fullSize Dims) Dims

Calculate the size of an image scaled using this 'Geometry' object, relative to an image of the given size. 'fullSize' is taken into account only when the 'Percent' relative units are used.

func (Geometry) String

func (geom Geometry) String() string

Converts a 'Geometry' object into a string.

type GeometryDimension

type GeometryDimension struct {
	N float64
	U GeometryUnits
}

A unit-bearing image measurement.

type GeometryScaling

type GeometryScaling int

Types of scaling supported by the 'Geometry' type.

const (
	// Always scale, no matter the size of the image to be scaled.
	ScaleAlways GeometryScaling = iota
	// Scale only if the image is larger than the given size.
	ScaleDownOnly
	// Scale only if the image is smaller than the given size.
	ScaleUpOnly
)

type GeometryUnits

type GeometryUnits int

Units supported by the 'Geometry' type.

const (
	Pixels GeometryUnits = iota
	Percent
)

type IISBy

type IISBy func(lhs, rhs *ImageIdentifier) bool

A comparator for ImageIdentifiers, to be used in sorting images.

func (IISBy) Sort

func (by IISBy) Sort(ids []ImageIdentifier)

type IISorter

type IISorter struct {
	// contains filtered or unexported fields
}

func (*IISorter) Len

func (iis *IISorter) Len() int

func (*IISorter) Less

func (iis *IISorter) Less(i, j int) bool

func (*IISorter) Swap

func (iis *IISorter) Swap(i, j int)

type ImageIdentifier

type ImageIdentifier int

An identifier assigned to an input image as it is read in.

type ImageInfo

type ImageInfo interface {
	ImageId() ImageIdentifier
	FileName() string
	DimensionsOf() Dims
	ImageData() interface{}
}

Holds information about an input image.

func LoadImage

func LoadImage(id ImageIdentifier, fileName string, preload bool) ImageInfo

Loads an image for inclusion in an ImageLayout. If 'preload' is set, the entire image is loaded into memory; if not, only the header is read to obtain the dimensions.

type ImageInfo_impl

type ImageInfo_impl struct {
	// contains filtered or unexported fields
}

An ImageInfo implementation that stores all of an image's pixel data.

func (ImageInfo_impl) DimensionsOf

func (iii ImageInfo_impl) DimensionsOf() Dims

func (ImageInfo_impl) FileName

func (iii ImageInfo_impl) FileName() string

func (ImageInfo_impl) ImageData

func (iii ImageInfo_impl) ImageData() interface{}

func (ImageInfo_impl) ImageId

func (iii ImageInfo_impl) ImageId() ImageIdentifier

type ImageInfo_placeholder

type ImageInfo_placeholder struct {
	// contains filtered or unexported fields
}

An ImageInfo implementation that stores only the filename and dimension of an image and not all the pixel data.

func (ImageInfo_placeholder) DimensionsOf

func (iip ImageInfo_placeholder) DimensionsOf() Dims

func (ImageInfo_placeholder) FileName

func (iip ImageInfo_placeholder) FileName() string

func (ImageInfo_placeholder) ImageData

func (iip ImageInfo_placeholder) ImageData() interface{}

func (ImageInfo_placeholder) ImageId

func (iip ImageInfo_placeholder) ImageId() ImageIdentifier

type ImageLayout

type ImageLayout interface {
	// Most of the content of an ImageLayout is stored as a reference. This returns true if that is a nil reference.
	IsNil() bool
	// Creates a full copy of this ImageLayout.
	Duplicate() ImageLayout
	// The parameters assigned to this ImageLayout.
	Parameters() *Parameters
	// The total number of constituent images in this ImageLayout.
	TotalImageCount() int
	// The number of images in this ImageLayout that have been positioned in the collage.
	PositionedImageCount() int
	// Gets the size of the output image being generated.
	CanvasSize() Dims
	// Sets the size of the output image being generated.
	SetCanvasSize(d Dims)
	// Gets the list of images in this ImageLayout, a reference or a copy per the parameter.
	Images(copy bool) []ImageIdentifier
	// Gets the 'ImageInfo' for the given image.
	ImageInfoOf(img ImageIdentifier) ImageInfo
	// Clears all the position information set in this ImageLayout.
	ClearPositions() ImageLayout
	// Clears all the scaling information set in this ImageLayout.
	ClearDimensions() ImageLayout
	// Gets the position information for the given image.
	PositionOf(img ImageIdentifier) Dims
	// Sets the position information for the given image. Returns an ImageLayout including the new position
	// (which may or may not be the same object as the input ImageLayout) and, if the image as positioned
	// collided with another image, a pointer to that image.
	SetPosition(img ImageIdentifier, position Dims) (rv ImageLayout, collidedWith *ImageIdentifier)
	// Gets the dimensions of the given image as it will be placed on the canvas.
	DimensionsOf(img ImageIdentifier) Dims
	// Gets the cropping information for the given image.
	CroppingOf(img ImageIdentifier) Geometry
	// Sets the cropping information for the given image. Returns an ImageLayout including the new cropping information
	// (which may or may not be the same object as the input ImageLayout) and, if the image as positioned
	// collided with another image, a pointer to that image.
	SetCropping(img ImageIdentifier, geom Geometry) (rv ImageLayout, collidedWith *ImageIdentifier)
	// Gets the scaling information for the given image.
	ScalingOf(img ImageIdentifier) Geometry
	// Sets the scaling information for the given image. Returns an ImageLayout including the new scaling information
	// (which may or may not be the same object as the input ImageLayout) and, if the image as positioned
	// collided with another image, a pointer to that image.
	SetScaling(img ImageIdentifier, geom Geometry) (rv ImageLayout, collidedWith *ImageIdentifier)
	// Tests whether an image, positioned in the ImageLayout, collides with any others.
	TestCollision(newImage ImageIdentifier) *ImageIdentifier
}

Represents the layout of the collage: the positions and scaled/cropped dimensions of each constituent image.

func Balance

func Balance(iLay ImageLayout) ImageLayout

Run an iterative "balancing" algorithm on an existing image layout that attempts to center each image within the rectangle of blank space around it.

func CreateNilImageLayout

func CreateNilImageLayout() ImageLayout

Creates a "nil" image layout object (used to indicate an error).

type ImageLayout_impl

type ImageLayout_impl struct {
	// contains filtered or unexported fields
}

func (ImageLayout_impl) CanvasSize

func (iLay ImageLayout_impl) CanvasSize() Dims

func (ImageLayout_impl) ClearDimensions

func (iLay ImageLayout_impl) ClearDimensions() ImageLayout

func (ImageLayout_impl) ClearPositions

func (iLay ImageLayout_impl) ClearPositions() ImageLayout

func (ImageLayout_impl) CroppingOf

func (iLay ImageLayout_impl) CroppingOf(img ImageIdentifier) Geometry

func (ImageLayout_impl) DimensionsOf

func (iLay ImageLayout_impl) DimensionsOf(img ImageIdentifier) Dims

func (ImageLayout_impl) Duplicate

func (iLay ImageLayout_impl) Duplicate() ImageLayout

func (ImageLayout_impl) ImageInfoOf

func (iLay ImageLayout_impl) ImageInfoOf(img ImageIdentifier) ImageInfo

func (ImageLayout_impl) Images

func (iLay ImageLayout_impl) Images(copy bool) []ImageIdentifier

func (ImageLayout_impl) IsNil

func (iLay ImageLayout_impl) IsNil() bool

Most of the content of an ImageLayout is stored as a reference. This returns true if that is a nil reference.

func (ImageLayout_impl) Parameters

func (iLay ImageLayout_impl) Parameters() *Parameters

func (ImageLayout_impl) PositionOf

func (iLay ImageLayout_impl) PositionOf(img ImageIdentifier) Dims

func (ImageLayout_impl) PositionedImageCount

func (iLay ImageLayout_impl) PositionedImageCount() int

func (ImageLayout_impl) ScalingOf

func (iLay ImageLayout_impl) ScalingOf(img ImageIdentifier) Geometry

func (ImageLayout_impl) SetCanvasSize

func (iLay ImageLayout_impl) SetCanvasSize(d Dims)

func (ImageLayout_impl) SetCropping

func (iLay ImageLayout_impl) SetCropping(img ImageIdentifier, geom Geometry) (rv ImageLayout, collidedWith *ImageIdentifier)

func (ImageLayout_impl) SetPosition

func (iLay ImageLayout_impl) SetPosition(img ImageIdentifier, position Dims) (rv ImageLayout, collidedWith *ImageIdentifier)

func (ImageLayout_impl) SetScaling

func (iLay ImageLayout_impl) SetScaling(img ImageIdentifier, geom Geometry) (rv ImageLayout, collidedWith *ImageIdentifier)

func (ImageLayout_impl) TestCollision

func (iLay ImageLayout_impl) TestCollision(newImage ImageIdentifier) *ImageIdentifier

func (ImageLayout_impl) TotalImageCount

func (iLay ImageLayout_impl) TotalImageCount() int

type InputImageReader

type InputImageReader interface {
	CollageCreatorComponent
	// Read input images as specified in 'parameters';
	// return the ImageLayout object 'il' on success or error on failure.
	ReadInputImages(parameters *Parameters) (il ImageLayout, err error)
}

A superinterface for any object that reads images into a layout.

type InputImageReader_Raster

type InputImageReader_Raster struct {
	// contains filtered or unexported fields
}

An InputImageReader that reads raster images in any format supported by the Go 'image' library.

func InputImageReader_Raster_Init

func InputImageReader_Raster_Init() InputImageReader_Raster

func (InputImageReader_Raster) ParseCustomParameters

func (iicio InputImageReader_Raster) ParseCustomParameters(parameters *Parameters) bool

func (InputImageReader_Raster) ReadInputImages

func (iicio InputImageReader_Raster) ReadInputImages(parameters *Parameters) (il ImageLayout, err error)

func (InputImageReader_Raster) RegisterCustomParameters

func (iicio InputImageReader_Raster) RegisterCustomParameters(parameters *Parameters) bool

type InputImageReader_Raster_CustomParameters

type InputImageReader_Raster_CustomParameters struct {
	// contains filtered or unexported fields
}

type OutputImage

type OutputImage interface {
	WriteToFile(fileName string, parameters *Parameters)
}

A superinterface for any object that holds an image ready to write to a file.

type OutputImage_ImageMagickScript

type OutputImage_ImageMagickScript struct {
	// contains filtered or unexported fields
}

Produces output in the form of a Bash script that, when run, will call ImageMagick to produce the output collage.

func (OutputImage_ImageMagickScript) WriteToFile

func (ois OutputImage_ImageMagickScript) WriteToFile(fileName string, parameters *Parameters)

type OutputImage_SVG

type OutputImage_SVG struct {
	// contains filtered or unexported fields
}

Produces output in the form of an SVG file that links to all the input images.

func (OutputImage_SVG) WriteToFile

func (ois OutputImage_SVG) WriteToFile(fileName string, parameters *Parameters)

type OutputImage_image

type OutputImage_image struct {
	// contains filtered or unexported fields
}

Produces output in the form of a JPEG, PNG, or TIFF file, using Jan Schlicht's "resize" package to handle scaling.

func (OutputImage_image) WriteToFile

func (oii OutputImage_image) WriteToFile(fileName string, parameters *Parameters)

type Parameters

type Parameters struct {
	// contains filtered or unexported fields
}

Holds parameters to CollageCreator.

func Parameters_init

func Parameters_init() Parameters

Initializes a new instance of Parameters.

func (Parameters) AspectRatio

func (p Parameters) AspectRatio() (ratio float64, strict bool)

Gets the target aspect ratio for the final output image, in the form of a float and a boolean indicating whether this number is a preference or a strict requirement.

func (Parameters) AspectRatioGeometry

func (p Parameters) AspectRatioGeometry() Geometry

Gets the target aspect ratio for the final output image, in Geometry form.

func (Parameters) CollageRenderer

func (p Parameters) CollageRenderer() CollageRenderer

Gets the CollageRenderer to be used for this run.

func (Parameters) DimensionInitializer

func (p Parameters) DimensionInitializer() DimensionInitializer

Gets the DimensionInitializer to be used for this run.

func (Parameters) InFiles

func (p Parameters) InFiles() []string

Gets the list of pathnames representing input images.

func (Parameters) InputImageReader

func (p Parameters) InputImageReader() InputImageReader

Gets the InputImageReader to be used for this run.

func (Parameters) MaxCanvasSize

func (p Parameters) MaxCanvasSize() Dims

Gets the maximum acceptable size of the final output image (0 signifying no limit).

func (Parameters) MinCanvasSize

func (p Parameters) MinCanvasSize() Dims

Gets the minimum acceptable size of the final output image (0 signifying no limit).

func (Parameters) Other

func (p Parameters) Other(name string) (param interface{}, valid bool)

Gets a component-specific custom parameter by name, returning the value and a boolean that is false if the parameter has not been set.

func (Parameters) OtherBool

func (p Parameters) OtherBool(name string) bool

Gets by name a component-specific system parameter known to be a boolean, logging a fatal error if it is of any other type.

func (Parameters) OtherDims

func (p Parameters) OtherDims(name string) Dims

Gets by name a component-specific system parameter known to be of type 'Dims', logging a fatal error if it is of any other type.

func (Parameters) OtherFloat

func (p Parameters) OtherFloat(name string) float64

Gets by name a component-specific system parameter known to be a float, logging a fatal error if it is of any other type.

func (Parameters) OtherGeometry

func (p Parameters) OtherGeometry(name string) Geometry

Gets by name a component-specific system parameter known to be of type 'Geometry', logging a fatal error if it is of any other type.

func (Parameters) OtherInt

func (p Parameters) OtherInt(name string) int

Gets by name a component-specific system parameter known to be an integer, logging a fatal error if it is of any other type.

func (Parameters) OtherString

func (p Parameters) OtherString(name string) string

Gets by name a component-specific system parameter known to be a string, logging a fatal error if it is of any other type.

func (Parameters) OutFile

func (p Parameters) OutFile() string

Gets the pathname where the output is to be placed.

func (Parameters) Padding

func (p Parameters) Padding() Geometry

Gets the Geometry governing padding around images during placement.

func (Parameters) PositionCalculator

func (p Parameters) PositionCalculator() PositionCalculator

Gets the PositionCalculator to be used for this run.

func (Parameters) ProgressMonitor

func (p Parameters) ProgressMonitor() ProgressMonitor

Gets the ProgressMonitor used to report status.

func (*Parameters) SetAspectRatio

func (p *Parameters) SetAspectRatio(aspectRatio Geometry)

Gets the target aspect ratio for the final output image.

func (*Parameters) SetCollageRenderer

func (p *Parameters) SetCollageRenderer(collageRenderer CollageRenderer)

Sets the CollageRenderer to be used for this run.

func (*Parameters) SetDimensionInitializer

func (p *Parameters) SetDimensionInitializer(dimensionInitializer DimensionInitializer)

Sets the DimensionInitializer to be used for this run.

func (*Parameters) SetInFiles

func (p *Parameters) SetInFiles(inFiles []string)

Sets the list of pathnames representing input images.

func (*Parameters) SetInputImageReader

func (p *Parameters) SetInputImageReader(inputImageReader InputImageReader)

Sets the InputImageReader to be used for this run.

func (*Parameters) SetMaxCanvasSize

func (p *Parameters) SetMaxCanvasSize(maxCanvasSize Dims)

Gets the maximum acceptable size of the final output image (0 signifying no limit).

func (*Parameters) SetMinCanvasSize

func (p *Parameters) SetMinCanvasSize(minCanvasSize Dims)

Sets the minimum acceptable size of the final output image (0 signifying no limit).

func (Parameters) SetOther

func (p Parameters) SetOther(name string, value interface{})

Sets a component-specific parameter by name.

func (*Parameters) SetOutFile

func (p *Parameters) SetOutFile(outFile string)

Sets the pathname where the output is to be placed.

func (*Parameters) SetPadding

func (p *Parameters) SetPadding(padding Geometry)

Sets the Geometry governing padding around images during placement.

func (*Parameters) SetPositionCalculator

func (p *Parameters) SetPositionCalculator(positionCalculator PositionCalculator)

Sets the PositionCalculator to be used for this run.

func (*Parameters) SetProgressMonitor

func (p *Parameters) SetProgressMonitor(progressMonitor ProgressMonitor)

Sets the ProgressMonitor used to report status.

type PositionCalculator

type PositionCalculator interface {
	CollageCreatorComponent
	// Find a place on a canvas for each image in 'imageLayout'. Returns error on failure,
	// or 'il' on success, which may be, but is not guaranteed to be, a separate object
	// from 'imageLayout'.
	CalculatePositions(imageLayout ImageLayout) (il ImageLayout, err error)
}

A superinterface for any object that positions images on the collage.

type PositionCalculator_Random

type PositionCalculator_Random struct {
	// contains filtered or unexported fields
}

A PositionCalculator that places images randomly on the canvas.

func PositionCalculator_Random_Init

func PositionCalculator_Random_Init() PositionCalculator_Random

func (PositionCalculator_Random) CalculatePositions

func (pcr PositionCalculator_Random) CalculatePositions(imageLayout ImageLayout) (il ImageLayout, err error)

func (PositionCalculator_Random) ParseCustomParameters

func (pcr PositionCalculator_Random) ParseCustomParameters(parameters *Parameters) bool

func (PositionCalculator_Random) RegisterCustomParameters

func (pcr PositionCalculator_Random) RegisterCustomParameters(parameters *Parameters) bool

type PositionCalculator_TileInOrder

type PositionCalculator_TileInOrder struct {
	// contains filtered or unexported fields
}

A PositionCalculator that places images in a tiling pattern.

func PositionCalculator_TileInOrder_Init

func PositionCalculator_TileInOrder_Init() PositionCalculator_TileInOrder

func (PositionCalculator_TileInOrder) CalculatePositions

func (pcr PositionCalculator_TileInOrder) CalculatePositions(imageLayout ImageLayout) (il ImageLayout, err error)

func (PositionCalculator_TileInOrder) ParseCustomParameters

func (pcr PositionCalculator_TileInOrder) ParseCustomParameters(parameters *Parameters) bool

func (PositionCalculator_TileInOrder) RegisterCustomParameters

func (pcr PositionCalculator_TileInOrder) RegisterCustomParameters(parameters *Parameters) bool

type ProgressMonitor

type ProgressMonitor interface {
	CollageCreatorComponent
	// Reports an unstructured message.
	ReportMessage(msg string)
	// Reports an unstructured runtime error.
	ReportRuntimeError(msg string, err error)
	// Reports that positioning has failed.
	ReportPositioningFailure()
	// Reports that positioning has succeeded.
	ReportPositioningSuccess()
	// Reports a set of dimensions.
	ReportDims(msg string, dims Dims)
	// Reports the progress of rendering, in terms of images rendered and still to render.
	ReportRenderingProgress(currentImage int, imageCount int)
	// Reports that rendering was a success.
	ReportRenderingSuccess()
	// Reports that rendering was a failure.
	ReportRenderingFailure()
	// Reports that output to a given file was a success.
	ReportOutputSuccess(fileName string)
	// Reports that output to a given file was a failure.
	ReportOutputFailure(fileName string)
	// Reports the progress of the random layout method:
	// the canvas size being tried; the number of canvas sizes tried so far and still to be tried;
	// the number of images positioned and still to be positioned; the number of attempts made
	// and still to make to position the current image.
	ReportRandomPositioningProgress(canvasSize Dims, currentCanvasTry int, maxCanvasTries int, currentPositionedCount int, totalImageCount int, currentImageTry int, maxImageTries int)
	// Reports the progress of the random layout method.
	ReportTileInOrderPositioningProgress(canvasSize Dims, badness tileInOrder_Badness)
	// Reports the progress of the whitespace-balancing post-process of the random layout method:
	// how many balancing steps have been taken; whether horizontal or vertical whitespace
	// is being balanced; how many iterations of balancing have been taken in the current
	// step; the maximum amount of whitespace imbalance still existing.
	ReportBalanceProgress(step int, dimIndex int, iteration int, maxImbalance int)
	// Reports a collision or overlap between two positioned images -- normally should not happen.
	ReportBalanceCollision(img ImageIdentifier, fileName string, oldPos Dims)
	// Reports that the whitespace-balancing post-process of the random layout method was a success.
	ReportBalancingSuccess()
	// Reports that the whitespace-balancing post-process of the random layout method was a failure.
	ReportBalancingFailure()
}

A superinterface for any object that reports the progress of the collage creator.

type ProgressMonitor_impl

type ProgressMonitor_impl struct{}

func ProgressMonitor_Init

func ProgressMonitor_Init() ProgressMonitor_impl

func (ProgressMonitor_impl) ParseCustomParameters

func (pmi ProgressMonitor_impl) ParseCustomParameters(parameters *Parameters) bool

func (ProgressMonitor_impl) RegisterCustomParameters

func (pmi ProgressMonitor_impl) RegisterCustomParameters(parameters *Parameters) bool

func (ProgressMonitor_impl) ReportBalanceCollision

func (pmi ProgressMonitor_impl) ReportBalanceCollision(img ImageIdentifier, fileName string, oldPos Dims)

func (ProgressMonitor_impl) ReportBalanceProgress

func (pmi ProgressMonitor_impl) ReportBalanceProgress(step int, dimIndex int, iteration int, maxImbalance int)

func (ProgressMonitor_impl) ReportBalancingFailure

func (pmi ProgressMonitor_impl) ReportBalancingFailure()

func (ProgressMonitor_impl) ReportBalancingSuccess

func (pmi ProgressMonitor_impl) ReportBalancingSuccess()

func (ProgressMonitor_impl) ReportDims

func (pmi ProgressMonitor_impl) ReportDims(msg string, dims Dims)

func (ProgressMonitor_impl) ReportMessage

func (pmi ProgressMonitor_impl) ReportMessage(msg string)

func (ProgressMonitor_impl) ReportOutputFailure

func (pmi ProgressMonitor_impl) ReportOutputFailure(fileName string)

func (ProgressMonitor_impl) ReportOutputSuccess

func (pmi ProgressMonitor_impl) ReportOutputSuccess(fileName string)

func (ProgressMonitor_impl) ReportPositioningFailure

func (pmi ProgressMonitor_impl) ReportPositioningFailure()

func (ProgressMonitor_impl) ReportPositioningSuccess

func (pmi ProgressMonitor_impl) ReportPositioningSuccess()

func (ProgressMonitor_impl) ReportRandomPositioningProgress

func (pmi ProgressMonitor_impl) ReportRandomPositioningProgress(canvasSize Dims, currentCanvasTry int, maxCanvasTries int, currentPositionedCount int, totalImageCount int, currentImageTry int, maxImageTries int)

func (ProgressMonitor_impl) ReportRenderingFailure

func (pmi ProgressMonitor_impl) ReportRenderingFailure()

func (ProgressMonitor_impl) ReportRenderingProgress

func (pmi ProgressMonitor_impl) ReportRenderingProgress(currentImage int, imageCount int)

func (ProgressMonitor_impl) ReportRenderingSuccess

func (pmi ProgressMonitor_impl) ReportRenderingSuccess()

func (ProgressMonitor_impl) ReportRuntimeError

func (pmi ProgressMonitor_impl) ReportRuntimeError(msg string, err error)

func (ProgressMonitor_impl) ReportTileInOrderPositioningProgress

func (pmi ProgressMonitor_impl) ReportTileInOrderPositioningProgress(canvasSize Dims, badness tileInOrder_Badness)

Jump to

Keyboard shortcuts

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