The loader module¶
The loader module depends on the MagickWand C-library. Make sure it is installed before using this module.
On Linux and MacOS, the loader module will try to search for MagickWand in the folder set by the environment variable
MAGICK_HOME. This is substantially faster than the alternate method so it is recommended to set this environment variable before importing
from chafa.loader import Loader import chafa config = chafa.CanvasConfig() canvas = chafa.Canvas(config) loader = Loader("./example.jpg") canvas.draw_all_pixels( loader.pixel_type, loader.get_pixels(), loader.width, loader.height, loader.rowstride ) print(canvas.print().decode())
Loader is a reasonably fast way to load the pixel data of an image for use with chafa.py. In addition to loading the pixel data, the
Loader will also provide useful information such as the width and height of the image to further simplify drawing to the
- class chafa.loader.Loader(path: str)¶
path (str) – The path to the image to load. This will not resolve special characters such as
FileNotFoundError – if the image does not exist.