protected function _rotateRight() { if (empty($_GET['current']) || false == ($current = $this->_findDir(trim($_GET['current']))) || empty($_GET['target']) || false == ($target = $this->_find(trim($_GET['target']), $current))) { return $this->_result['error'] = 'Invalid parameters'; } if (!$this->_isAllowed($target, 'read')) { return $this->_result['error'] = 'Access denied'; } $info = @getimagesize($target); if ($info) { $image = new JO_Thumb($target); $image->rotate(-90); $image->save($target); } $this->_rmTmb($target); $this->_result['select'] = array($this->_hash($target)); $this->_content($current); }
public function resize($filename, $width, $height, $crop = false, $watermark = false, $gray = false, $auto = false) { if (!$width && !$height) { $width = 1; $height = 1; } if (!file_exists($this->dirImages . $filename) || !is_file($this->dirImages . $filename)) { $filename = JO_Registry::forceGet('no_image'); if (!$filename || !file_exists($this->dirImages . $filename) || !is_file($this->dirImages . $filename)) { $filename = 'no_image.jpg'; if (!file_exists($this->dirImages . $filename) || !is_file($this->dirImages . $filename)) { return; } } } $info = pathinfo($filename); $extension = $info['extension']; $gray_name = ''; if ($gray) { $gray_name = '-gray'; } if ($crop) { $gray_name .= '-crop'; } if ($watermark) { $gray_name .= '-watermark'; } if ($auto == 'width') { $whe = $width . 'x'; } elseif ($auto == 'height') { $whe = 'x' . $height; } else { $whe = $width . 'x' . $height; } $old_image = $filename; $tmp = substr($filename, 0, strrpos($filename, '.')); $filename = substr($filename, 0, strrpos($filename, '.')); // $filename = substr($tmp, 0, strrpos($tmp, '/')) . '/' . md5(basename($tmp)) . '-' . md5($filename); $new_image = 'cache' . $filename . '-' . $whe . $gray_name . '.' . $extension; $new_image = str_replace('/../', '/', $new_image); $this->temp_sizes = array('width' => $width, 'height' => $height); if (!file_exists($this->dirImages . $new_image) || filemtime($this->dirImages . $old_image) > filemtime($this->dirImages . $new_image)) { $path = ''; $directories = explode('/', dirname(str_replace('../', '', $new_image))); foreach ($directories as $directory) { $path = $path . '/' . $directory; if (!file_exists($this->dirImages . $path)) { @mkdir($this->dirImages . $path, 0777, true); } } $image = new JO_Thumb($this->dirImages . $old_image); if (function_exists('exif_read_data')) { $exif = exif_read_data($this->dirImages . $old_image); if (isset($exif['Orientation'])) { switch ($exif['Orientation']) { case 8: $image->rotate(-90); break; case 3: $image->rotate(180); break; case 6: $image->rotate(90); break; } } } if ($crop === false) { $image->resize($width, $height); } else { $image->resize_crop($width, $height); } if ($watermark && JO_Registry::get($watermark) && file_exists(BASE_PATH . '/uploads/' . JO_Registry::get($watermark))) { $image->watermark(BASE_PATH . '/uploads/' . JO_Registry::get($watermark), false); } $image->save($this->dirImages . $new_image, $gray); } if (file_exists($this->dirImages . $new_image)) { $this->temp_sizes['date_added'] = filemtime($this->dirImages . $new_image); } return $this->request->getBaseUrl() . $this->httpImages . $new_image; }