/** * Tests the JImage::destory method * * @return void * * @since 12.3 */ public function testDestroy() { // Create an image handle $imageHandle = imagecreatetruecolor(100, 100); // Pass created handle to JImage $image = new JImage($imageHandle); // Destroying the image should return boolean true $this->assertTrue($image->destroy()); }
/** * Create a cropped and resized image from the uploaded original * * @return bool * * @since 1.0.0.3 */ protected function createImage($src, $dest, $width, $height) { $original = new JImage($src); $org_width = $original->getWidth(); $org_height = $original->getHeight(); if ($org_width / $width < $org_height / $height) { $original->resize($width, 0, false); } else { $original->resize(0, $height, false); } $thumb = $original->crop($width, $height, null, null, true); $filename = pathinfo($original->getPath(), PATHINFO_FILENAME); $extension = pathinfo($original->getPath(), PATHINFO_EXTENSION); if (!$thumb->toFile(JPATH_ROOT . $dest . $filename . "." . $extension)) { return false; } $original->destroy(); $thumb->destroy(); return true; }