Intervention \ Image \ Exception \ NotReadableException using laravel 4

前端 未结 4 1953
难免孤独
难免孤独 2020-12-17 21:07

I\'m using laravel 4 and I installed the Intervention Image package. When I\'m using it in my code whith method -

相关标签:
4条回答
  • 2020-12-17 21:42

    this in solution

    $filename = str_slug($products->name)."-0.jpg";
    $filename_fb = 'fb-'.$filename;
    $filename_tw = 'tw-'.$filename;
    
    $img = Image::make($_FILES['photo']['tmp_name']);
    // resize image
    $img->resize(800, 400);
    // save image
    $img->save($path.'/'.$filename);
    
    0 讨论(0)
  • 2020-12-17 21:54

    if you use a sub-folder in your public path, use chmod to change the permission on that folder e.g cd public; chmod -Rv 755 public/{your_path_name};

    Run

    man chmod;
    

    for more details

    0 讨论(0)
  • 2020-12-17 21:58

    Change this:

    $file = Image::make('url_Avatar');
    

    To this:

    $file = Input::file('url_Avatar');
    // ...
    $filename = '...';
    Image::make($file->getRealPath())->resize('200','200')->save($filename);
    

    Read more about file on Laravel documentation.

    0 讨论(0)
  • 2020-12-17 22:03

    I have the same problem. When I change image driver everything works fine.

    Try to change image driver from app/config/packages/intervention/image/config.php from GD to Imagick

    If you cant find config file try to run commands below:

    Publish configuration in Laravel 5

    $ php artisan vendor:publish --provider="Intervention\Image\ImageServiceProviderLaravel5"

    Publish configuration in Laravel 4

    $ php artisan config:publish intervention/image

    Example content from config file:

    return array(
    
        /*
        |--------------------------------------------------------------------------
        | Image Driver
        |--------------------------------------------------------------------------
        |
        | Intervention Image supports "GD Library" and "Imagick" to process images
        | internally. You may choose one of them according to your PHP
        | configuration. By default PHP's "GD Library" implementation is used.
        |
        | Supported: "gd", "imagick"
        |
        */
    
        'driver' => 'imagick'
    
    );
    
    0 讨论(0)
提交回复
热议问题