img_lib_attach()

Initialize the image library

Synopsis:

#include <img.h>

int img_lib_attach( img_lib_t*  ilib );

Arguments:

ilib
The address where the function stores a handle to the library.

Library:

img

Description:

This function initializes the image library, looks for a configuration file, and loads the codecs listed in that file.

If the function can't find a configuration file, it still fills in a valid library handle, but no codecs are loaded, and images can't be decoded. In this situation, the function returns IMG_ERR_CFG. You can load codecs after library initialization by calling img_cfg_read().

The img.conf Configuration File

The image library uses a configuration file to determine which codecs to load, This function first checks the environment variable LIBIMG_CFGFILE, which is the full path for the configuration file. If it isn't set, then checks the default location /etc/system/config/img.conf.

Codecs in the configuration file are specified as sections. Each section of the configuration file is demarcated by the codec name in square brackets, followed by an unordered list of properties specifying additional information about that codec. There should be at least a mimetype line and list of extensions to associate with the codec. For example:

[img_codec_jpg.so]
mime=image/jpeg:image/jpg
ext=jpg:jpeg

Note: This example illustrates how to specify multiple entries in the same line, but has been simplified from the original. The default configuration file contains more mimetype entries.

Returns:

IMG_ERR_OK
Success.
IMG_ERR_MEM
Memory-allocation failure.
IMG_ERR_CFG
Bad or missing configuration file. The handle returned is still valid, however no codecs have been preloaded.

Classification:

Image library

Safety:
Interrupt handler No
Signal handler No
Thread No

See also:

img_cfg_read(), img_lib_detach()