public function resize($src, $dest = null, $width, $height, $quality, $sx = null, $sy = null, $sw = null, $sh = null) { jimport('joomla.filesystem.folder'); jimport('joomla.filesystem.file'); require_once dirname(__FILE__) . '/image/image.php'; if (!isset($dest) || $dest == '') { $dest = $src; } $ext = strtolower(JFile::getExt($src)); $src = @JFile::read($src); if ($src) { $image = new WFImage(null, $this->get('prefer_imagick', true)); $image->loadString($src); // set type $image->setType($ext); // cropped thumbnail if ((isset($sx) || isset($sy)) && isset($sw) && isset($sh)) { $image->crop($sw, $sh, $sx, $sy); } // resize $image->resize($width, $height); switch ($ext) { case 'jpg': case 'jpeg': $quality = intval($quality); if ($this->get('ftp', 0)) { @JFile::write($dest, $image->toString($ext, array('quality' => $quality))); } else { $image->toFile($dest, $ext, array('quality' => $quality)); } break; default: if ($this->get('ftp', 0)) { @JFile::write($dest, $image->toString($ext, array('quality' => $quality))); } else { $image->toFile($dest, $ext, array('quality' => $quality)); } break; } unset($image); unset($result); } if (file_exists($dest)) { @JPath::setPermissions($dest); return $dest; } return false; }