lundi 4 décembre 2017

Laravel Intervention/image memory_limit

In my floder I have 120MB of images. One image - near 3 MB. I try to use this code to resize them:

public function images_zip(Request $request){
    if($request->width < 1 || $request->hight < 1 || $request->width > 2000 || $request->hight >2000){
        return Redirect::back()->withErrors(['Некорректные входные данные']);
    }
    $files = Storage::disk('images')->files('/'.$request->name.'/image');
    $mime_types = array('image/gif','image/jpeg','image/png','image/svg+xml');
    ini_set('memory_limit','128M');
    foreach ($files as $file){
        if(in_array(File::mimeType($file),$mime_types)) {
            $img = Image::make(public_path() . '/' . $file);
                $img->resize($request->width, $request->hight);
                $img->save(public_path() . '/' . $file);
                $img->destroy();
        }
    }
    return \redirect()->back();
}

But I take this error -

Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes)

I tried to use ->destroy() and ini_set('memory_limit','128M') ,like people say, but it didnt help. My server have 128MB memory. Help me,please!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire