Bonjour,
J'utilise la librairie imagine pour le traitement de mes images. Tout fonctionne correctement, mais maintenant je n'arrive plus à afficher mes images j'ai l'erreur suivante :
Error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 39923713 bytes)
File: phar:/imagine.phar/Gd/Image.php
Line: 2
Notice: If you want to customize this error message, create app/View/Errors/fatal_error.ctp
Voici le code que j'ai récupérer sur un tuto.
public function image($image, $width, $height, $options = array()){
$options'width'] = $width;
$options'height'] = $height;
return $this->Html->image($this->resizedUrl($image, $width, $height), $options);
}
public function resizedUrl($image, $width, $height){
$this->pluginDir = dirname(dirname(dirname(__FILE__)));
$image = trim($image, '/');
$pathinfo = pathinfo($image);
$dest = sprintf(str_replace(".{$pathinfo'extension']}", '_%sx%s.jpg', $image), $width, $height);
$image_file = WWW_ROOT . $image;
$dest_file = WWW_ROOT . $dest;
// On a déjà le fichier redimensionné ?
if (!file_exists($dest_file)){
require_once 'phar://' . 'imagine.phar';
$imagine = new Imagine\Gd\Imagine();
try{
//$angle = $this->__getRotation( $image_file ); // This method doesn't work for everyone
$angle = 0;
$imagine->open($image_file)->rotate( $angle )->thumbnail(new Imagine\Image\Box($width, $height), Imagine\Image\ImageInterface::THUMBNAIL_OUTBOUND)->save($dest_file, array('quality' => 60));
} catch (Imagine\Exception\Exception $e) {
$alternates = glob(str_replace(".{$pathinfo'extension']}",".*", $image_file));
if(empty($alternates)){
return '/img/error.jpg';
}else{
try{
$imagine->open($alternates[0])->thumbnail(new Imagine\Image\Box($width, $height), Imagine\Image\ImageInterface::THUMBNAIL_OUTBOUND)->save($dest_file, array('quality' => 60));
} catch (Imagine\Exception\Exception $e) {
return '/img/error.jpg';
}
}
}
}
unset($image);
return '/' . $dest;
}
J'ai essayé ini_set('memory_limit', 400); //J'ai essayé toutes les valeurs possibles lol
Quelqu'un pourrait-il me renseigner ?
Merci
Mickael