#! /usr/local/bin/perl -w

	# get all ps files and change them into jpg files

@ps_files = </users/asc/level2/data/mag/orig_data/acesummary_2008*.ps>;

foreach (@ps_files){
	$ps_fn = $_;
	$jpg_fn = $_;
	$jpg_fn =~ s/.*acesummary(_\d+-\d+).*ps/MAGSUMMARY${1}.jpg/;
	# print $jpg_fn, "\n";
	### change postscript into ppm files
	print "$_  ", `pstopnm -xsize 2048 $_`;
	### change $_ to the output filename of "pstopnm"
	s/.*(acesummary_\d+-\d+.*)\.ps/${1}001\.ppm/;
	print "$_ > $jpg_fn\n";
	### change ppm to jpg
	`convert -resize 512 -quality 95 $_ $jpg_fn`;
	### remove the ppm file
	print `rm $_`;

	# move the original PS file to the ps/ directory
#	`mv $ps_fn /users/asc/level2/data/mag/ps/`;
}

