curl_setopt($ch, CURLOPT_POSTFIELDS, $query); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($ch, CURLOPT_TIMEOUT, 6000); $data = curl_exec($ch); curl_close($ch); $pcadata = json_decode($data, true); if (!is_array($pcadata) || !array_key_exists('error', $pcadata) || $pcadata['error'] == 'true') { $return['errorText'] = $data; } else { $return['data'] = $pcadata; if (!empty($pcadata['img'])) { // save image and associated tem include_once DOC_ROOT . '/include/classes/psychomorph.class.php'; $avgimg = "/.tmp/" . $pcadata['img']; $avgtem = "/.tmp/" . $pcadata['tem']; $img = new PsychoMorph_ImageTem($avgimg, $avgtem); $img->setDescription(array('Desc' => 'Average image for PCA model ' . $theData['pcafile'] . '.pca', 'images' => $theData['images'], 'texture' => $theData['texture'], 'norm' => 'rigid')); $newFileName = ifEmpty($theData['pcafile'], $theData['pcifile']); if ($img !== null && $img->save($newFileName)) { $return['error'] = false; $return['newFileName'] = $img->getImg()->getURL(); } else { $return['errorText'] .= 'The image was not saved. '; $return['newFileName'] = $newFileName; } } } } scriptReturn($return); exit;
auth(); checkAllocation(); $return = array('error' => false, 'errorText' => ''); include_once DOC_ROOT . '/include/classes/psychomorph.class.php'; $img = new PsychoMorph_ImageTem($_POST['img']); $t = $_POST['t']; $r = $_POST['r']; $b = $_POST['b']; $l = $_POST['l']; $x = $_POST['x']; $y = $_POST['y']; $w = $_POST['w']; $h = $_POST['h']; $rgb = $_POST['rgb']; if ($t !== '' && $r !== '' && $b !== '' && $l !== '') { $orig_w = $img->getImg()->getWidth(); $orig_h = $img->getImg()->getHeight(); $w = $orig_w + $l + $r; $h = $orig_h + $t + $b; $x = -1 * $l; $y = -1 * $t; } else { if ($x !== '' && $y !== '' && $w !== '' && $h !== '') { // do nothing } else { $return['error'] = true; $return['errorText'] = 'There was not enough information to crop the images.'; } } if (!$return['error']) { $newFileName = array('subfolder' => $_POST['subfolder'], 'prefix' => $_POST['prefix'], 'suffix' => $_POST['suffix'], 'ext' => $_POST['ext']);