public static function getPrev($img,$sfx='-prewXS',$width=150, $height=150,$quility=5,$refresh=false) {
jimport( 'joomla.filesystem.file' );
jimport('joomla.image.image');
$prevPath=JFile::stripExt($img).$sfx.'.jpg';
if(JFile::exists( JPATH_ROOT.'/'.$prevPath) && !$refresh) {
return $prevPath;
}
$prev = new JImage();
$prev->loadFile(JPATH_ROOT.$img);
$resize=$prev->resize($width, $height, true, JImage::SCALE_INSIDE );
$resize->toFile(JPATH_ROOT.$prevPath, IMAGETYPE_JPEG, array('quality'=>$quility));
return $prevPath;
}