gieseladev / mosaic

A collage generator primarily designed to generate stunning playlist thumbnails
MIT License
4 stars 1 forks source link

use this project as a library #3

Open ghost opened 4 years ago

ghost commented 4 years ago

Hi,

Hope you are all well !

Is it possible to provide a snippet/gist for using mosaic like library in go program ? For eg, like, https://github.com/deiwin/picasso

Thanks for any insights or inputs on that.

Cheers, X

siku2 commented 4 years ago

I'm afraid the only thing I can offer is telling you to look at the CLI code: https://github.com/gieseladev/mosaic/blob/master/cmd/mosaic/main.go#L105-L128

The basic idea is:

  1. Get a Composer for instance with mosaic.RecommendComposers(len(images))
  2. Create a new drawing context with your desired dimensions: gg.NewContext(dimensions)
  3. Call composer.Compose with the drawing context and the images you wish to use
  4. The drawing context now contains the composition, you can do with it whatever you want

Alternatively, instead of using a Composer, you can call the algorithm directly: mosaic.CirclesPie(<drawing context>, <images>...)

Please be aware that we never got to a point where this library was used so it presumably has tons of issues and the code is likely outdated. If you're interested in the composer algorithms, you should probably just extract them from the library.