Initialize the image library
#include <img/img.h> int img_lib_attach( img_lib_t* ilib );
- The address where the function stores a handle to the library.
Use the -l img option to qcc to link against this library.
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
- Memory-allocation failure.
- Bad or missing configuration file. The handle returned is still valid, however no codecs have been preloaded.