Answer the question
In order to leave comments, you need to log in
Why does the Imagine error occur?
I'm trying to organize the cropping of files (but it turned out that initially) no one cropped them, so I had to take information about finding photos from the database, here's the code itself
$image=Image::find()->all();
$imgcrop=$imagine->imagerisize($image);
public function imagerisize($models){
foreach($models as $model) {
$path = Yii::getAlias('@frontend/web/image/') . $model->path;
$img = Image::getImagine()->open($path . '/' . $model->name);
$size = $img->getSize();
$ratio = $size->getWidth() / $size->getHeight();
$widthcar = 200;
$heightcar = round($widthcar / $ratio);
Image::thumbnail($path . '/' . $model->name, $widthcar, $heightcar)->save($path . 'carusel-' . $model->name, ['quality' => 90]);
$widthind = 240;
$heightind = round($widthind / $ratio);
Image::thumbnail($path . '/' . $model->name, $widthind, $heightind)->save($path . 'index-' . $model->name, ['quality' => 90]);
$widthcat = 220;
$heightcat = round($widthcat / $ratio);
Image::thumbnail($path . '/' . $model->name, $widthcat, $heightcat)->save($path . 'category-' . $model->name, ['quality' => 90]);
$widthtop = 92;
$heighttop = round($widthtop / $ratio);
Image::thumbnail($path . '/' . $model->name, $widthtop, $heighttop)->save($path . 'top-' . $model->name, ['quality' => 90]);
$widthnews = 42;
$heightnews = round($widthnews / $ratio);
Image::thumbnail($path . '/' . $model->name, $widthnews, $heightnews)->save($path . 'news-' . $model->name, ['quality' => 90]);
unset($model);
}
return true;
}
Imagine\Exception\RuntimeException
Save operation failed
Caused by: ImagickException
Insufficient memory (case 4)
Answer the question
In order to leave comments, you need to log in
Looking for a translation from English? Imagick complains about running out of memory. Options for action:
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question