Index: branches/eam_branches/ipp-20120905/Ohana/src/delstar/src/delete_image_photcodes.c
===================================================================
--- branches/eam_branches/ipp-20120905/Ohana/src/delstar/src/delete_image_photcodes.c	(revision 34691)
+++ branches/eam_branches/ipp-20120905/Ohana/src/delstar/src/delete_image_photcodes.c	(revision 34691)
@@ -0,0 +1,47 @@
+# include "delstar.h"
+
+void delete_image_photcodes (FITS_DB *db) {
+
+  off_t i, j;
+  off_t  Nimage, Noutimage;
+  Image *image;
+  Image *outimage;
+
+  // xxx where does this go?
+  int Nphotcodes = 0;
+  PhotCode **photcodes = ParsePhotcodeList (PHOTCODE_LIST, &Nphotcodes, FALSE);
+
+  image = gfits_table_get_Image (&db[0].ftable, &Nimage, &db[0].swapped);
+  if (!image) {
+    fprintf (stderr, "ERROR: failed to read images\n");
+    exit (2);
+  }
+
+  /* delete the identified images */
+  int Noutimage = 0;
+  ALLOCATE (outimage, Image, Nimage);
+  for (i = 0; i < Nimage; i++) {
+    int drop = FALSE;
+    for (j = 0; !drop && (j < Nphotcodes); j++) {
+      drop |= (photcodes[j][0].code == image[i].photcode);
+    }
+    if (drop) continue;
+    outimage[Noutimage] = image[i];
+    Noutimage ++;
+  }
+  free (image);
+  
+  if (VERBOSE) fprintf (stderr, "removing "OFF_T_FMT" images (leaving "OFF_T_FMT" of "OFF_T_FMT")\n",  Noutimage - Nimage, Noutimage, Nimage);
+  // gfits_table_set_Image (&db[0].ftable, outimage, Noutimage);
+
+  gfits_modify (&db[0].theader, "NAXIS2", OFF_T_FMT, 1,  Noutimage);
+  gfits_modify (&db[0].header, "NIMAGES", OFF_T_FMT, 1,  Noutimage);
+  db[0].theader.Naxis[1] = Noutimage;
+  db[0].ftable.buffer = (char *) outimage;
+
+  dvo_image_save (db, VERBOSE);
+  dvo_image_unlock (db);
+
+  fprintf (stderr, "SUCCESS\n");
+  exit (0);
+}
Index: branches/eam_branches/ipp-20120905/Ohana/src/delstar/src/delstar.c
===================================================================
--- branches/eam_branches/ipp-20120905/Ohana/src/delstar/src/delstar.c	(revision 34690)
+++ branches/eam_branches/ipp-20120905/Ohana/src/delstar/src/delstar.c	(revision 34691)
@@ -29,5 +29,5 @@
       break;
     case MODE_PHOTCODES: {
-      // delete_image_photcodes (&db);
+      delete_image_photcodes (&db);
 
       // load the current sky table (layout of all SkyRegions) 
