[Solved]Reading File Paths from a text File
Posted: 2012-04-25T23:27:40-07:00
Hi every one,
Iam trying to read paths of images from a text file and load them into wands...im getting a status problem...can anyone please help me with it and i want to write all images with a different file name ..im trying something like this...
To write the image...m is a loop variable...it is an integer..
Thanks in advance.
Iam trying to read paths of images from a text file and load them into wands...im getting a status problem...can anyone please help me with it and i want to write all images with a different file name ..im trying something like this...
Code: Select all
int main(int argc,char **argv)
{
MagickWand *magick_wand;
FILE *fp;
fp = fopen("./filenames.txt", "r");
char str[200];
if (argc != 4)
{
(void) fprintf(stdout,"Usage: %s image \n",argv[0]);
exit(0);
}
/*
Read an image.
*/
MagickWandGenesis(); // to initialize the magick-wand Environment
magick_wand=NewMagickWand(); // To create the wand to store image
printf("Loading Image....");
while(fgets(str,sizeof(str),fp) != NULL)
{
status=MagickReadImage(magick_wand,str); // Function to read image into wand
if (status == MagickFalse)
{
printf ("status problem");
}
v.sbimg_wdt=v.sbimg_hgt=atoi(argv[2]);
v.treshold=atoi(argv[3]);
subimages_pxls(magick_wand,v,argv);
magick_wand=DestroyMagickWand(magick_wand); // To Destroy the image in the wand
MagickWandTerminus();// To terminate the magick-wand Environment
}
return(0);
}
Code: Select all
MagickBooleanType status;
printf("Writing New Image.....");
status=MagickWriteImages(wand,"res[m].png",MagickTrue);
if (status == MagickFalse)
{
printf ("status problem");
}