resize collection pic 120 * 24 max

This commit is contained in:
Nicolas Le Goff
2012-06-25 10:20:04 +02:00
parent 0cdeed79ca
commit d99018d740

View File

@@ -10,6 +10,7 @@
*/
use Symfony\Component\HttpFoundation\File\File as SymfoFile;
use MediaAlchemyst\Specification\Image as ImageSpecification;
/**
*
@@ -101,6 +102,20 @@ class appbox extends base
if ( ! in_array(mb_strtolower($pathfile->getMimeType()), array('image/gif', 'image/png', 'image/jpeg', 'image/jpg', 'image/pjpeg'))) {
throw new \InvalidArgumentException('Invalid file format');
}
//resize collection logo
$imageSpec = new ImageSpecification();
$imageSpec->setResizeMode(ImageSpecification::RESIZE_MODE_INBOUND_FIXEDRATIO);
$imageSpec->setDimensions(120, 24);
try {
$core['media-alchemyst']
->open($pathfile->getPathname())
->turninto($pathfile->getPathname(), $imageSpec)
->close();
} catch (\MediaAlchemyst\Exception $e) {
}
}
switch ($pic_type) {
@@ -132,7 +147,7 @@ class appbox extends base
$core['file-system']->remove($target);
}
if (is_null($target)) {
if (null === $target || null === $pathfile) {
continue;
}