require_once $_SERVER['DOCUMENT_ROOT'] . '/include/main_func.php'; auth(); checkAllocation(); $return = array('error' => false, 'errorText' => ''); $newWidth = $_POST['w']; $newHeight = $_POST['h']; include_once DOC_ROOT . '/include/classes/psychomorph.class.php'; $tem = IMAGEBASEDIR . preg_replace('@\\.(jpg|png|gif)$@', '.tem', $_POST['img']); if (file_exists($tem)) { $img = new PsychoMorph_ImageTem($_POST['img']); } else { $img = new PsychoMorph_Image($_POST['img']); } if ($newWidth > 0 && $newHeight > 0) { // calculate resize dimensions based on exact pixels for both dimensions $w = $img->getWidth(); $h = $img->getHeight(); $xResize = $newWidth / $w; $yResize = $newHeight / $h; } else { if ($newWidth > 0) { // calculate resize dimensions based on exact width and same % height $w = $img->getWidth(); $xResize = $newWidth / $w; $yResize = $xResize; } else { if ($newHeight > 0) { // calculate resize dimensions based on exact height and same % width $h = $img->getHeight(); $yResize = $newHeight / $h; $xResize = $yResize;
<?php // get the LAB colour values from an image require_once $_SERVER['DOCUMENT_ROOT'] . '/include/main_func.php'; auth(); $return = array('error' => true, 'errorText' => ''); include_once DOC_ROOT . '/include/classes/psychomorph.class.php'; $theImg = new PsychoMorph_Image($_POST['img']); if ($image = $theImg->getImage()) { $return['width'] = $theImg->getWidth(); $return['height'] = $theImg->getHeight(); $return['newFileName'] = preg_replace('/(jpg|gif|png)$/', 'csv', $_POST['img']); $filename = IMAGEBASEDIR . $return['newFileName']; $filecontents = "x,y,L,a,b\n"; if ($_POST['ignore_mask'] == 'true') { $mask_color = imagecolorat($image, 0, 0); $return['ignore_mask'] = $mask_color; } else { $mask_color = -1; $return['ignore_mask'] = $mask_color; } for ($x = 0; $x < $return['width']; $x++) { for ($y = 0; $y < $return['height']; $y++) { $color_index = imagecolorat($image, $x, $y); if ($color_index != $mask_color) { $r = $color_index >> 16 & 0xff; $g = $color_index >> 8 & 0xff; $b = $color_index & 0xff; $lab = rgb2lab($r, $g, $b); $l = round($lab['L'], 4); $a = round($lab['a'], 4);