function ingest_specimen_image()
{
    $specimen_image_successfully_ingested = "false";
    $rft_id = $_POST['rft_id'];
    $original_url = $_POST['original_url'];
    $jp2_url = $_POST['jp2_url'];
    $institution = $_POST['institution'];
    $collector = $_POST['collector'];
    $collection_number = $_POST['collection_number'];
    $collection_date = $_POST['collection_date'];
    $scientific_name = $_POST['scientific_name'];
    if (isset($_POST['rft_id'])) {
        include_once drupal_get_path('module', 'apiary_project') . '/adore-djatoka/functions_djatoka.php';
        module_load_include('php', 'Apiary_Project', 'fedora_commons/class.AP_Specimen');
        $new_specimen = new AP_Specimen();
        $specimen_label = '';
        if ($new_specimen->createSpecimenObject($collector, $collection_number, $collection_date, $scientific_name, $specimen_label)) {
            $specimen_image_successfully_ingested = "true";
            module_load_include('php', 'Apiary_Project', 'fedora_commons/class.AP_Image');
            $new_image = new AP_Image();
            list($width, $height) = getimagesize($jp2_url);
            $image_label = '';
            $jpeg_datastream_url = getDjatokaURL($rft_id, 'getRegion', '4', '0', '0', $height, $width, '', '');
            if ($new_image->createImageObject($new_specimen->pid, $jp2_url, $rft_id, $original_url, $width, $height, $jpeg_datastream_url, $image_label)) {
                $msg = 'Specimen ' . $new_specimen->pid . ' and image ' . $new_image->pid . ' successfully created.<br>';
            } else {
                $msg = 'Unable to create a new image. Specimen ' . $new_specimen->pid . ' successfully created.<br>';
            }
        } else {
            $msg = 'Unable to create a new specimen or image object.<br>';
        }
    }
    $returnJSON['specimen_image_successfully_ingested'] = $specimen_image_successfully_ingested;
    $returnJSON['msg'] = $msg;
    echo json_encode($returnJSON);
}
          $jp2_file = trim(fgets($file));
          $jp2URL = $jp2URL_base.$jp2_file;
          $sourceURL = $sourceURL_base.substr($jp2_file, 0, -4).'.tif';
          $jp2_rft_id = $rft_id . substr($jp2_file, 0, -4);
          if($handle = @fopen($jp2URL, 'r')) {
            module_load_include('php', 'Apiary_Project', 'fedora_commons/class.AP_Specimen');
            $new_specimen = new AP_Specimen();
            $specimen_label = '';
            if($new_specimen->createSpecimenObject('', '', '', '', $specimen_label)) {
              module_load_include('php', 'Apiary_Project', 'fedora_commons/class.AP_Image');
              $new_image = new AP_Image();
              //Ultimately this will have a djatoka plugin check the resolver db and add records as needed
	          list($width, $height) = getimagesize($jp2URL);
              $image_label = '';
              $jpeg_datastream_url = getDjatokaURL($jp2_rft_id, 'getRegion', '4', '0', '0', $height, $width, '', '');
              if($new_image->createImageObject($new_specimen->pid, $jp2URL, $jp2_rft_id, $sourceURL, $width, $height, $jpeg_datastream_url, $image_label)) {
                echo 'Specimen '.$new_specimen->pid.' and image '.$new_image->pid.' successfully created.<br>';
              }
              else {
                echo 'Unable to create a new image. Specimen '.$new_specimen->pid.' successfully created.<br>';;
              }
            }
            else {
              echo 'Unable to create a new specimen.<br>';
            }
            fclose($handle);
          }
          else {
            echo 'The url '.$jp2URL.' is invalid! <br>';
          }
          $i++;