#include <stdio.h>
#include <string.h>
#include "tiff.c"
#define MAXSIZE 9000000 //this may need increasing for large images

char buffer[MAXSIZE], rbuffer[MAXSIZE];
char from_str[65], to_str[65];
int width, length, from, to ;
char newfname[145];

int main (int argc,char** argv) {

	memset(buffer,0,MAXSIZE);
	memset(rbuffer,0,MAXSIZE);
	strncpy(newfname,argv[1],65);
	strncpy(from_str,argv[2],65);
	strncpy(to_str,argv[3],65);
	from = atoi(from_str);
	to = atoi(to_str);
	sprintf(newfname, "%s.sliced.%d.tif", newfname, from);
	tiff_read (&width, &length, argv[1], buffer); 
	tiff_slice (width, length, buffer, from, to, rbuffer);
	tiff_write (width, to-from, newfname, rbuffer);
}
