function get_djatoka_url_by_height($image_pid, $height)
{
    $djatoka_display_url = '';
    $imageMetadata_record = AP_Image::getimageMetadata_record($image_pid);
    $rft_id = $imageMetadata_record['rft_id'];
    if ($rft_id != '') {
        $djatoka_display_url = getDjatokaURL($rft_id, 'getRegion', '3', '0', '0', $imageMetadata_record['h'], $imageMetadata_record['w'], '0', $height);
    } else {
        $djatoka_display_url = getDjatokaURL($imageMetadata_record['URL'], 'getRegion', '3', '0', '0', $imageMetadata_record['h'], $imageMetadata_record['w'], '0', $height);
    }
    return $djatoka_display_url;
}
function getImageMetadata($image_pid, $operation, $workflow_id)
{
    $image_metadata = AP_Image::getimageMetadata_record($image_pid);
    if ($operation == "rft_id") {
        echo json_encode($image_metadata);
    } else {
        $url = "http://demo.apiaryproject.org:8080/adore-djatoka/resolver?url_ver=Z39.88-2004&rft_id=" . $image_metadata['URL'] . "&svc_id=info:lanl-repo/svc/getMetadata";
        $send = curl_init();
        curl_setopt($send, CURLOPT_URL, $url);
        curl_setopt($send, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($send, CURLINFO_HEADER_OUT, 1);
        $output = curl_exec($send);
        if (curl_errno($send)) {
            return false;
        } else {
            $info = curl_getinfo($send);
            if ($info['http_code'] == 200) {
                echo $output;
            } else {
                return false;
            }
        }
    }
}