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