Sunday, May 20, 2018

Using Intervention package to compress images. My images are not being compressed, still the same size - development

Using Intervention package to compress images. My images are not being compressed, still the same size

I’m using this package http://image.intervention.io/getting_started/installation to compress my images that’s uploaded to my server. However the images are not being compressed.

  1. First I installed the Intervention package by putting this in my
    terminal:

    composer require intervention/image

  2. Then I added this at the top of my controller:

    use InterventionImageImageManagerStatic as Image;

  3. Then I added the encode to minify the image

    Image::make(request()->file(‘img’))->encode(‘jpg’, 1);

  4. It’s not minifying the image. It’s still the same size.

    <?php
    
    namespace AppHttpControllers;
    
    use InterventionImageImageManagerStatic as Image;
    use IlluminateSupportFacadesStorage;
    use IlluminateHttpRequest;
    
    class UploadsController extends Controller
    {
    
        public function store()
        {
    
            // Get image
            $img = request()->file('img');
    
            // Minify image
            Image::make($img)->encode('jpg', 1);
    
            // Store image in uploads folder
            Storage::disk('public')->put('uploads', $img);
    
        }
    
    }
    
    


from Laravel Questions and Answers https://laravelquestions.com/php/using-intervention-package-to-compress-images-my-images-are-not-being-compressed-still-the-same-size/
via Lzo Media

No comments:

Post a Comment