#include #include #include #include "Path.h" #include "Image.h" //------------------------------------------------------------------------------ #define MIN_SUBDIR_COUNT 7 #define MAX_SUBDIR_COUNT 11 char * subDirNames []= { "cranium", "chin", "ears", "nose", "mouth", "eyes", "eyebrows", "beard", "moustache", "hair", "glasses" }; //------------------------------------------------------------------------------ int main (int argc, char * argv[]) { if (argc != 1+2 && argc != 1+3) { fprintf (stderr, "Usage: %s DIR SEED [FILE]\n", argv[0]); exit (1); } char * baseDirName= argv[1]; int seed= atoi (argv[2]); char * filename= (argc == 1+3) ? argv[3] : NULL; srand (seed); MagickWandGenesis(); MagickWand * face= Image_randomFace (baseDirName, subDirNames, MIN_SUBDIR_COUNT, MAX_SUBDIR_COUNT); if (filename == NULL) MagickDisplayImage(face, getenv ("DISPLAY")); else if ( ! MagickWriteImage (face, filename)) { fprintf (stderr, "Error: failed to write image to '%s'\n", filename); } DestroyMagickWand (face); MagickWandTerminus(); return 0; }