#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>

main()
{
    FILE *f,*g;
    char buf[500],name[500],buf1[500];
    int Ev,Ho,Old,lEv,lHo,sp;
    struct stat st;

    lEv = lHo = -1;
    f = popen("ls -1 /tmp/komal/B*.PS","r");
    while (fgets(name,500,f))
    {
	while ((strlen(name)>0) && (name[strlen(name)-1] <= ' '))
	    name[strlen(name)-1]=0;
	sprintf(buf1,"echo quit | gs -q -dNOPAUSE -sDEVICE=bmp16m -r110x110 -sOutputFile=/tmp/komal/pg.bmp %s",name);
	system(buf1);
	if (name[strlen(name)-4] == '1')
    	    sprintf(buf1,"convert -colorspace YUV -colors 256 -crop 600x900+160+120 /tmp/komal/pg.bmp %s.png",name);
	else
    	    sprintf(buf1,"convert -colorspace YUV -colors 256 -crop 600x900+96+120 /tmp/komal/pg.bmp %s.png",name);
	system(buf1);
    }
}

