protected function _createResized($original, $destination, $params) { if (!isset($params['x']) && !isset($params['y']) && !isset($params['maxx']) && !isset($params['maxy'])) { copy($original, $destination); } else { $ph = new traitephoto(); $ph->photo = $original; $ph->path = dirname($destination); $ph->nomsouhaite = basename($destination); $ph->qualite = $params['q']; $ph->width = $params['x']; $ph->height = $params['y']; $ph->maxx = $params['maxx']; $ph->maxy = $params['maxy']; $ph->resize(); $name = $ph->save($params['format']); } return; }
function _regenerateThumbUnit($photo, $v, &$obj, $field) { $firstRedim = true; if (!isset($v['x']) && !isset($v['y']) && !isset($v['maxx']) && !isset($v['maxy']) && !isset($v['overlay'])) { copy($photo, IMAGES_UPLOAD_FOLDER . $v['path'] . '/' . $obj->{$field}); $name = $obj->{$field}; } else { $ph = new traitephoto(); $ph->photo = $photo; $ph->path = IMAGES_UPLOAD_FOLDER . $v['path']; $ph->nomsouhaite = $obj->{$field}; $ph->qualite = $v['quality']; $ph->width = $v['x']; $ph->height = $v['y']; $ph->maxx = $v['maxx']; $ph->maxy = $v['maxy']; if (isset($v['overlay']) && $firstRedim) { $type = 'png'; $ph->path = FileUtils::getFolderPath(TMP_PATH); $ph->nomsouhaite = 'overlaytemp.png'; } else { $type = $v['type'] ? $v['type'] : null; } $ph->resize(); $name = $ph->save($type); if (isset($v['overlay']) && $firstRedim) { $source = $v['path'] . '/' . $name; $infosSource =& Image_Transform::factory('GD'); if (PEAR::isError($infosSource)) { throw new Exception($infosSource->getMessage()); } $tmp = FileUtils::getFolderPath(TMP_PATH); $infosSource->load($tmp . 'overlaytemp.png'); $infosOver =& Image_Transform::factory('GD'); $infosOver->load(APP_ROOT . $v['overlay'][0]); $opts = array('width' => $infosSource->getImageWidth(), 'height' => $infosSource->getImageHeight(), 'transparent' => true); $img =& Image_Canvas::factory('png', $opts); $img->image(array('filename' => TMP_PATH . 'overlaytemp.png', 'x' => 0, 'y' => 0)); switch ($v['overlay']['position']) { case 'top-left': $x = 0; $y = 0; break; case 'top-right': $x = $infosSource->getImageWidth() - $infosOver->getImageWidth(); $y = 0; break; case 'bottom-left': $x = 0; $y = $infosSource->getImageHeight() - $infosOver->getImageHeight(); break; case 'bottom-right': $x = $infosSource->getImageWidth() - $infosOver->getImageWidth(); $y = $infosSource->getImageHeight() - $infosOver->getImageHeight(); break; default: $x = 0; $y = 0; break; } $img->image(array('filename' => APP_ROOT . $v['overlay'][0], 'x' => $x, 'y' => $y)); $img->save(array('filename' => $tmp . 'overlaytemp.png')); $ph = new traitephoto(); $ph->photo = $tmp . 'overlaytemp.png'; $ph->path = IMAGES_UPLOAD_FOLDER . $v['path']; $ph->nomsouhaite = $obj->{$field}; $ph->qualite = $v['quality']; $ph->resize(); $name = $ph->save($v['type'] ? $v['type'] : null); unset($ph); } } if ($name != $obj->{$field}) { @unlink(IMAGES_UPLOAD_FOLDER . $v['path'] . '/' . $obj->{$field}); } unset($ph); return $name; }