/** * Resize an image using the sfThubmnail Plugin. * * @param string $originalImageName * @param integer $width * @param integer $height * * @return string (thumbnail's bitstream) */ public static function resizeImage($originalImageName, $width = null, $height = null) { $mimeType = QubitDigitalObject::deriveMimeType($originalImageName); // Get thumbnail adapter if (!($adapter = self::getThumbnailAdapter())) { return false; } // Check that this file can be thumbnailed, or return false if (self::canThumbnailMimeType($mimeType) == false) { return false; } // Create a thumbnail try { $newImage = new sfThumbnail($width, $height, true, false, 75, $adapter, array('extract' => 1)); $newImage->loadFile($originalImageName); } catch (Exception $e) { return false; } return $newImage->toString('image/jpeg'); }