#!/usr/bin/perl
#for ($counter=0; $counter<=200 $counter++) {
###while (defined($nextname = <p???????.jpg>)) {

#while (defined($nextname = <p00009??.jpg>)) {
while (defined($nextname = <r???.jpg>)) {
  # create filenames
  # $filev = sprintf("v%03d.jpg", $counter);
  $filefullsize = $nextname;
  $files = sprintf("s%s", $filefullsize);
  $files =~ s/sr/s/;
  printf("about to generate $files from $filefullsize\n");
  # `mv $filed $filev`;
  `djpeg $filefullsize > deleteme_big.ppm`;
  `pnmscale -xscale .32 -yscale .32 deleteme_big.ppm > deleteme_small.ppm`;
  `cjpeg -quality 95 deleteme_small.ppm > $files`
}

