ImageGear for C and C++ on Linux v20.0 - Updated
IG_image_batch_convert
API Reference Guide > Core Component API Reference > Core Component Functions Reference > General Image Functions > IG_image_batch_convert

This function is designed to convert a specified set of files from one ImageGear-supported image format type to another.

Declaration:

 
Copy Code
AT_ERRCOUNT ACCUAPI IG_image_batch_convert(
        LPAT_SRCINFO lpSrcInfo, 
        LPAT_DSTINFO lpDstInfo, 
        const LPSTR lpcszLogFileName
);

Arguments:

Name Type Description
lpSrcInfo LPAT_SRCINFO A long pointer to a structure of type AT_SRCINFO through which you supply ImageGear with the source directory and format type of the files to be converted. See details below.
lpDstInfo LPAT_DSTINFO A long pointer to a structure of type AT_DSTINFO in which you supply ImageGear with the destination directory, format type, and naming convention for the newly converted files. See details below.
lpcszLogFileName const LPSTR Set this string to a filename for a log file to be generated. The log file will contain a list of files successfully converted, and any images that caused errors. If you do not need a log file, set this to NULL.

Return Value:

Returns the number of ImageGear errors that occurred during this function call. If there are no errors, the return value is IGE_SUCCESS.

Supported Raster Image Formats:

All pixel formats supported by ImageGear for C and C++.

Example:

 
Copy Code
AT_ERRCOUNT   nErrcount;
LPAT_DSTINFO  DstInfo;
LPAT_SRCINFO  SrcInfo;
SrcInfo.lpcszSrcDir = "c:\public\source\images";
SrcInfo.lpcszSrcFilter = "*.bmp;*.tif";
DstInfo.lpcszDstDir = "c:\public\richard\joe\rich";
DstInfo.DstNamingConv = IG_BATCH_USE_SRC_NAME;
DstInfo.DstSaveType = IG_SAVE_TIF_UNCOMP;
/* convert all .bmp and .tif files from c:\public\source\images to TIFF uncompressed
images and store the coverted images to the destination directory
c:\public\richard\joe\rich, using the TIFF uncompressed file format*/
nErrcount = IG_image_batch_convert(&SrcInfo, &DstInfo," c:\\public\\log.txt");

Remarks:

The function takes three parameters: the source information (a structure of type AT_SRCINFO), the destination information (a structure of type AT_DSTINFO), and a const LPSTR to which you specify the path\filename of the log file to create.

AT_SRCINFO is a structure that contains the source file information:

 
Copy Code
typedef struct tag AT_SRCINFO
{
   LPSTR lpcszSrcDir; /* source dir from which files will be gathered */
   LPSTR lpcszSrcFilter;/* source filter for files contained on the 
                                                             source dir*/
}AT_SRCINFO, FAR *LPAT_SRCINFO;

The source information structure must be completed entirely; no fields may be left out. The lpcszSrcDir should be a NULL-terminated string of characters representing the source directory, or where the images that are to be converted will be read from (ex. "c:\public\source\images"). The lpcszSrcFilter should be a NULL-terminated string of characters that represents what type of images should be converted. You may specify more than one type of image to be converted, e.g."*.bmp;*.tif". Each individual filter should be separated by a semicolon.

The LPAT_DSTINFO is a structure that contains the file destination information.

 
Copy Code
typedef struct tag AT_DSTINFO
{
LPSTR lpcszDstDir;      /*destination directory */
AT_LMODE DstOptions;       /*destination naming convention*/
AT_LMODE DstSaveType;      /*destination save type */
} AT_DSTINFO, FAR *LPAT_DSTINFO;

The destination information structure must be completed entirely; no fields may be left out. The lpcszDstDir argument should be a NULL-terminated string of characters that represents where the images that are to be converted will be stored after they are converted. This directory may or may not exist at the time this function is called. If the directory does not exist this function will create it (ex. "c:\public\destination\images"). If the source image is a multi-page image and the destination format type supports multiple pages, a new multi-page file will be created. If the source image is a multi-page image and the destination save type does not support multiple pages, the resulting destination image file or files will be determined by the naming convention that you supply to the AT_DSTINFO structure. If the naming convention IG_BATCH_USE_SRC_NAME is used, there will be one destination file which is continually overwritten by each subsequent page, and will ultimately contain only the last page of the original source file.

The DstNamingConv should contain one of the predefined constants from accucnst.h, in the section under "*Batch Naming Conventions*". Currently, the following naming conventions are available:

IG_BATCH_USE_SRC_NAME: This naming convention will use the source file name, remove the extension and replace it with the new save type default extension for naming each of the converted images. The DstSaveType should be one of the save types defined in the accucnst.h file (ex.IG_SAVE_TIF_UNCOMP).

You must enter a valid path and filename when you set lpczLogFileName.where the path that you specify already exists. If lpcszLogFileName is set to a valid filename, any pre-existing file will be overwritten with the new conversion information. If there is no such file, it will be created. The format of the log file, lpcszLogFileName, if the user has chosen to generate one, will be as follows for image files that are successfully converted:

 
Copy Code
Image:<Src file name> <src format, src comp>  Converted: <Dst file name> <dst format, dst
comp>
Image:<Src file name> <src format, src comp>  Converted: <Dst file name> <dst format, dst
comp>
Image:<Src file name> <src format, src comp>  Converted: <Dst file name> <dst format, dst
comp>
Image:<Src file name> <src format, src comp>  Converted: <Dst file name> <dst format, dst
comp>
...

If any image files cause errors during the convert, the format of the log file will be as follows:

 
Copy Code
Image:<Src file name> <src format, src comp> <error type> <error code number> >
Image:<Src file name> <src format, src comp> <error type> <error code number> >
Image:<Src file name> <src format, src comp> <error type> <error code number> >
Is this page helpful?
Yes No
Thanks for your feedback.