}
                if (!array_key_exists('TN', $existingDatastreams)) {
                    $fileToLoad = $otherImageLocation . '/tn/' . $baseImageFilename . '.jpg';
                    addDatastream($fileToLoad, 'TN', 'Thumbnail', 'image/jpg', $existingPID, $objectId, $datastreamFile, $repository);
                }
                if (!array_key_exists('LC', $existingDatastreams)) {
                    $fileToLoad = $otherImageLocation . '/lc/' . $baseImageFilename . '.png';
                    addDatastream($fileToLoad, 'LC', 'Large Image for Pika', 'image/png', $existingPID, $objectId, $datastreamFile, $repository);
                }
                if (!array_key_exists('MC', $existingDatastreams)) {
                    $fileToLoad = $otherImageLocation . '/mc/' . $baseImageFilename . '.png';
                    addDatastream($fileToLoad, 'MC', 'Medium Image for Pika', 'image/png', $existingPID, $objectId, $datastreamFile, $repository);
                }
                if (!array_key_exists('SC', $existingDatastreams)) {
                    $fileToLoad = $otherImageLocation . '/sc/' . $baseImageFilename . '.png';
                    addDatastream($fileToLoad, 'SC', 'Small Image for Pika', 'image/png', $existingPID, $objectId, $datastreamFile, $repository);
                }
            }
            usleep(250);
        }
    }
}
/**
 * @param $fileToLoad
 * @param $datastream
 * @param $datastreamLabel
 * @param $mimeType
 * @param $existingPID
 * @param $objectId
 * @param $datastreamFile
 * @param FedoraRepository $repository
                //Find the TIFF and JP2 for the basic image
                $tifImage = $baseImageLocation . '/' . $migratedIdentifier . '.tif';
                $jp2Image = $jp2ImageLocation . '/' . $migratedIdentifier . '.jp2';
                if (!file_exists($tifImage)) {
                    fwrite($logFile, "  {$tifImage} Did not exist, skipping\r\n");
                    continue;
                }
                if (!file_exists($jp2Image)) {
                    fwrite($logFile, "  {$jp2Image} Did not exist, skipping\r\n");
                    continue;
                }
                //Add the JP2 image
                addDatastream($jp2Image, 'JP2', 'JPEG 2000', 'image/jpg2', $fedoraObject, $logFile);
                //Replace the OBJ with the TIFF
                $fedoraObject->purgeDatastream('OBJ');
                addDatastream($tifImage, 'OBJ', $migratedIdentifier . '.tif', 'image/tiff', $fedoraObject, $logFile);
                //Change the model for the record to large image model rather than basic
                unset($fedoraObject->models);
                $fedoraObject->models = array('islandora:sp_large_image_cmodel');
                //Remove the record from the basic image collection
                $fedoraObject->relationships->add(FEDORA_RELS_EXT_URI, 'isMemberOfCollection', 'islandora:sp_large_image_collectiont');
                $fedoraObject->relationships->remove(FEDORA_RELS_EXT_URI, 'isMemberOfCollection', 'islandora:sp_basic_image_collection');
                //wait for 30 seconds to let the islandora server catch up
                sleep(30);
            }
            $startRecord += $limit;
        }
    }
}
/**
 * @param $fileToLoad