Index: trunk/psphot/src/psphotTest.c
===================================================================
--- trunk/psphot/src/psphotTest.c	(revision 5993)
+++ trunk/psphot/src/psphotTest.c	(revision 6117)
@@ -15,10 +15,5 @@
 int main (int argc, char **argv) {
 
-    psMetadata *row;
-    psArray *table;
-
-    psMetadataItem *mdi;
     psRegion region = {0,0,0,0};	// a region representing the entire array
-
     psphotTestArguments (&argc, argv);
 
@@ -27,4 +22,31 @@
     psImage *image = psFitsReadImage (NULL, file, region, 0);
     psFitsClose (file);
+
+    psImageJpegColormap (argv[5]);
+
+    // psImage *fimage = psImageCopy (NULL, image, PS_TYPE_F32);
+
+    int binning = atof(argv[6]);
+
+    psStats *stats = psStatsAlloc (PS_STAT_SAMPLE_MEAN);
+    psImage *fimage = psImageRebin (NULL, image, NULL, 0, binning, stats);
+
+    float min = atof(argv[3]);
+    float max = atof(argv[4]);
+
+    psImageJpeg (fimage, argv[2], min, max);
+
+    psFree (header);
+    psFree (image);
+    exit (0);
+}
+
+
+# if (0)
+
+    psMetadata *row;
+    psArray *table;
+
+    psMetadataItem *mdi;
 
     psMetadataConfigWrite (header, argv[2]);
@@ -59,8 +81,4 @@
     psFitsWriteHeader (header, fits);
     psFitsWriteTable (fits, theader, table);
-    psFitsClose (fits);
 
-    psFree (header);
-    psFree (image);
-    exit (0);
-}
+# endif
