public static function createGrayscaleThumb($path, $type = 'grayscale') { $myImage = new JImage(); $myImage->loadFile(JPATH_CACHE . DS . $path); if ($myImage->isLoaded()) { // $filename = end(explode('/',$path)); $filename = JFile::getName($path); $newfilename = 'gr_' . JFile::makeSafe($filename); $fileExists = JFile::exists(JPATH_CACHE . '/' . $newfilename); if (!$fileExists) { //require_once JPATH_LIBRARIES . DS . 'joomla/image/filters/'.$type.'.php'; $libfile = JPATH_LIBRARIES . DS . 'joomla/image/filter' . (JVERSION <= 3 ? 's' : '') . '/' . $type . '.php'; if (JFile::exists($libfile)) { require_once $libfile; $filteredImage = $myImage->filter($type); $filteredImage->toFile(JPATH_CACHE . '/' . $newfilename); } } return $newfilename; } else { return "My file is not loaded"; } }
/** * Test the JImage::filter method without a loaded image. * * @return void * * @expectedException LogicException * @since 11.3 */ public function testFilterWithoutLoadedImage() { // Create a new JImage object without loading an image. $image = new JImage(); $image->filter('negate'); }