Skip to content

A Go-language library for the automatic generation of image collages.

License

Notifications You must be signed in to change notification settings

schwerdf/CollageCreator

Repository files navigation

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.

About

A Go-language library for the automatic generation of image collages.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages