Mosayc#

Main module.

class mosayc.mosayc.ImageInfo(path)[source]#
Parameters:

path (Path or str) – Path to the image.

Examples

>>> img = ImageInfo('example/main.jpeg')
>>> img  
img(...main.jpeg, size=1024x1024 (1/1), color=[75.18568993 59.76046181 26.39377594])
>>> ImageInfo('not_a_file_that_exists.jpeg')
Traceback (most recent call last):
...
ValueError: File not_a_file_that_exists.jpeg does not exists.
property pil#

The PIL Image object.

class mosayc.mosayc.Mosayc(**kwargs)[source]#
Parameters:

kwargs (dict) – Cf get_parameters()

Examples

>>> mosayc = Mosayc(root_dir='example', quotas=1, scale=.4)
>>> img = mosayc.compute()
>>> img.size
(409, 409)

Command line usage:

>>> import subprocess
>>> result = subprocess.run(["mosayc", "--help"], capture_output=True, text=True)
>>> print(result.stdout)  
Usage: mosayc [OPTIONS]

  Console script for mosayc.

Options:
  -I, --input PATH         Location of the main photo  [default: main.jpeg]
  -O, --output PATH        Mosaic name  [default: mosaic.jpeg]
  -D, --tiles_dir PATH     Location of the tiles directory  [default: tiles]
  -S, --scale FLOAT        Scaling factor of main photo  [default: 3.0]
  -T, --tilt FLOAT         Max tilt of tiles  [default: 10.0]
  -C, --color_shift FLOAT  Color adjustment intensity  [default: 100.0]
  -Q, --quotas INTEGER     Max number of copies of a tile  [default: 3]
  -R, --root_dir PATH      Working directory  [default: .]
  --help                   Show this message and exit.

Some errors:

>>> Mosayc(not_expected=True)
Traceback (most recent call last):
...
TypeError: Mosayc got an unexpected keyword argumment: not_expected
class mosayc.mosayc.Numerology(*, big_width: int, big_height: int, x: int, y: int, tile_width: int, tile_height: int)[source]#
model_config: ClassVar[ConfigDict] = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].