Categorygithub.com/schwerdf/CollageCreator
modulepackage
0.1.0
Repository: https://github.com/schwerdf/collagecreator.git
Documentation: pkg.go.dev

# 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.

# Functions

Run an iterative "balancing" algorithm on an existing image layout that attempts to center each image within the rectangle of blank space around it.
No description provided by the author
No description provided by the author
No description provided by the author
Runs the complete collage-creation process from reading input files to producing the output file; returns 0 if successful and nonzero if not.
Creates a "nil" image layout object (used to indicate an error).
No description provided by the author
Generates an "empty" 'Geometry' object in which all numeric values are 'NaN'.
No description provided by the author
Loads an image for inclusion in an ImageLayout.
A front-end to 'ParseDims' that logs a fatal error if the string does not parse.
A front-end to 'ParseGeometry' that logs a fatal error if the string does not parse.
Creates a new 'Dims' object.
No description provided by the author
Calculates the padding to be maintained around the given image.
Determines whether the padding to be maintained around the given image is in relative or absolute units.
Initializes a new instance of Parameters.
Parses a string into a 'Dims' object.
Parses a string into a 'Geometry' object.
No description provided by the author
No description provided by the author
No description provided by the author
Apply both the 'Scale' and 'Crop' methods to a given image, in that order.

# Constants

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Always scale, no matter the size of the image to be scaled.
Scale only if the image is larger than the given size.
Scale only if the image is smaller than the given size.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Structs

Produces output in the form of a Bash script that, when run, will call ImageMagick to produce the output collage.
Produces output in the form of a JPEG, PNG, or TIFF file, using Jan Schlicht's "resize" package to handle scaling.
Produces output in the form of an SVG file that links to all the input images.
The simplest 'DimensionInitializer': sends all images through as-is.
A 'DimensionInitializer' that applies uniform cropping and scaling rules, specified as ImageMagick geometry strings, to all input images.
No description provided by the author
No description provided by the author
Holds a pair of floats representing dimensions or coordinates.
Represents the geometry of an image operation such as cropping or scaling, as parsed from an ImageMagick-like "geometry" string.
A unit-bearing image measurement.
No description provided by the author
An ImageInfo implementation that stores all of an image's pixel data.
An ImageInfo implementation that stores only the filename and dimension of an image and not all the pixel data.
No description provided by the author
An InputImageReader that reads raster images in any format supported by the Go 'image' library.
No description provided by the author
Produces output in the form of a JPEG, PNG, or TIFF file, using Jan Schlicht's "resize" package to handle scaling.
Produces output in the form of a Bash script that, when run, will call ImageMagick to produce the output collage.
Produces output in the form of an SVG file that links to all the input images.
Holds parameters to CollageCreator.
A PositionCalculator that places images randomly on the canvas.
A PositionCalculator that places images in a tiling pattern.
No description provided by the author

# Interfaces

A superinterface for any object that adds custom parameters to the CollageCreator CLI.
A superinterface for any object that renders a finished image layout to a ready-to-write output image.
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).
Holds information about an input image.
Represents the layout of the collage: the positions and scaled/cropped dimensions of each constituent image.
A superinterface for any object that reads images into a layout.
A superinterface for any object that holds an image ready to write to a file.
A superinterface for any object that positions images on the collage.
A superinterface for any object that reports the progress of the collage creator.

# Type aliases

A map holding "custom" parameters specific to one component.
Types of scaling supported by the 'Geometry' type.
Units supported by the 'Geometry' type.
A comparator for ImageIdentifiers, to be used in sorting images.
An identifier assigned to an input image as it is read in.