Leptonica 1.68
C Image Processing Library

convertfilestopdf.c

Go to the documentation of this file.
00001 /*====================================================================*
00002  -  Copyright (C) 2001 Leptonica.  All rights reserved.
00003  -  This software is distributed in the hope that it will be
00004  -  useful, but with NO WARRANTY OF ANY KIND.
00005  -  No author or distributor accepts responsibility to anyone for the
00006  -  consequences of using this software, or for whether it serves any
00007  -  particular purpose or works at all, unless he or she says so in
00008  -  writing.  Everyone is granted permission to copy, modify and
00009  -  redistribute this source code, for commercial or non-commercial
00010  -  purposes, with the following restrictions: (1) the origin of this
00011  -  source code must not be misrepresented; (2) modified versions must
00012  -  be plainly marked as such; and (3) this notice may not be removed
00013  -  or altered from any source or modified source distribution.
00014  *====================================================================*/
00015 
00016 /*
00017  * convertfilestopdf.c
00018  *
00019  *    Converts all image files in the given directory with matching substring
00020  *    to a pdf, with the specified scaling factor <= 1.0 applied to all
00021  *    images.
00022  *
00023  *    See below for syntax and usage.
00024  *
00025  *    The images are displayed at a resolution that depends on the
00026  *    input resolution (res) and the scaling factor (scalefact) that
00027  *    is applied to the images before conversion to pdf.  Internally
00028  *    we multiply these, so that the generated pdf will render at the
00029  *    same resolution as if it hadn't been scaled.  By downscaling, you
00030  *    reduce the size of the images.  For jpeg, downscaling reduces
00031  *    pdf size by the square of the scale factor.  It also regenerates
00032  *    the jpeg with quality = 75.
00033  */
00034 
00035 #include <string.h>
00036 #include "allheaders.h"
00037 
00038 main(int    argc,
00039      char **argv)
00040 {
00041 char        *dirin, *substr, *title, *fileout;
00042 l_int32      ret, res;
00043 l_float32    scalefactor;
00044 static char  mainName[] = "convertfilestopdf";
00045 
00046     if (argc != 7) {
00047         fprintf(stderr,
00048             " Syntax: convertfilestopdf dirin substr res"
00049             " scalefactor title fileout\n"
00050             "         dirin:  input directory for image files\n"
00051             "         substr:  Use 'allfiles' to convert all files\n"
00052             "                  in the directory.\n"
00053             "         res:  Input resolution of each image;\n"
00054             "               assumed to all be the same\n"
00055             "         scalefactor:  Use to scale all images\n"
00056             "         title:  Use 'none' to omit\n"
00057             "         fileout:  Output pdf file\n");
00058         return 1;
00059     }
00060 
00061     dirin = argv[1];
00062     substr = argv[2];
00063     res = atoi(argv[3]);
00064     scalefactor = atof(argv[4]);
00065     title = argv[5];
00066     fileout = argv[6];
00067     if (!strcmp(substr, "allfiles"))
00068         substr = NULL;
00069     if (scalefactor <= 0.0 || scalefactor > 1.0) {
00070         L_WARNING("invalid scalefactor: setting to 1.0", mainName);
00071         scalefactor = 1.0;
00072     }
00073     if (!strcmp(title, "none"))
00074         title = NULL;
00075 
00076     ret = convertFilesToPdf(dirin, substr, res, scalefactor,
00077                             75, title, fileout);
00078     return ret;
00079 }
00080 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines