Easily convert images with Glide

Overview

Easily convert images with Glide

Latest Version Test Status Code Style Status Software License Total Downloads

This package provides an easy to use class to manipulate images. Under the hood it leverages Glide to perform the manipulations.

Here's an example of how the package can be used:

GlideImage::create($pathToImage)
	->modify(['w'=> 50, 'filt'=>'greyscale'])
	->save($pathToWhereToSaveTheManipulatedImage);

Support us

We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.

Installation

You can install the package through Composer.

composer require spatie/laravel-glide

In Laravel 5.5 the service provider and facade will automatically get registered. In older versions of the framework just add the service provider and facade in config/app.php file:

'providers' => [
    ...
    Spatie\Glide\GlideServiceProvider::class,
    ...
];

...

'aliases' => [
	...
    'GlideImage' => Spatie\Glide\GlideImageFacade::class,
    ...
]

You can publish the config file of the package using artisan.

php artisan vendor:publish --provider="Spatie\Glide\GlideServiceProvider"

The config file looks like this:

<?php

return [

    /*
     * The driver that will be used to create images. Can be set to gd or imagick.
     */
    'driver' => 'gd',
];

Usage

Here's a quick example that shows how an image can be modified:

GlideImage::create($pathToImage)
	->modify(['w'=> 50, 'filt'=>'greyscale'])
	->save($pathToWhereToSaveTheManipulatedImage);

Take a look at Glide's image API to see which parameters you can pass to the modify-method.

Testing

You can run the tests with:

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Previous versions

Previous versions of this package had PHP 5.4 support and the ability to generate images on the fly from an url.

The previous versions are unsupported, but they should still work in your older projects.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see LICENSE for more information.

Comments
  • 2.3.1 bugged

    2.3.1 bugged

    Since the latest update from v2 I get this errors:

    Internention\Image\Exception\NotSupportedException · GET /img/photos/_270_2101912-Foobarjpg_5735a2cb3519a
    Driver () could not be instantiated.
    
    opened by Jaspur 23
  • Changed the path and the baseURL, still searching in img

    Changed the path and the baseURL, still searching in img

    Hi, first of all thanks for your package.

    I published the config and modified it to adjust to my project, but when I inspect the HTML I see the glide is generating the URL pointing to img, also it can't process a load('folder/img.jpg'), it transforms to folder%2Fimg.jpg.

    Do you know how can I solve those problems?

    Thanks!

    help wanted 
    opened by Lloople 11
  • Call to undefined method Spatie\Glide\GlideImage::load()

    Call to undefined method Spatie\Glide\GlideImage::load()

    Hi I Just Downloaded This package and It's not woking I thing many files are missing:

    I did all this : composer require spatie/laravel-glide And configuration also,

    but in the vendor I can't see where is the route config even the laravel-glide.php is empty just the driver gd

    I can't see al that config when published. What IM doing wrong ?

    opened by TnCoders 9
  • The image is not resizing

    The image is not resizing

    So I followed all the steps and the image is loaded but with original dimensions.

    All my images are in the public folder and from what I can see using a debugger in the GlideServiceProvider, the router is not working. Maybe because my images are not in the storage folder?

    opened by RaoulBivolaru 8
  • Glide version 0.3.0

    Glide version 0.3.0

    Hey @freekmurze, thanks so much for putting this library together. I just wanted to let you know that I just released Glide version 0.3.0. I'll be honest, this release has many breaking changes from version 0.2.x. I apologize for that, but I did want to make all significant changes prior to an eventual 1.0 release. You can find the changelog here.

    I will note that I designed version 0.3.0 with Laravel 5 in mind. In fact, Taylor was even kind enough to accept a tweak to the new filesystem adapter in Laravel 5 to to allow access to underlying Flysystem driver. This allows you to use the already configured Flysystem instance with Glide. Here is a rough example:

    $this->app->singleton('League\Glide\Server', function ($app) {
    
        $filesystem = $this->app->make('Illuminate\Contracts\Filesystem\Filesystem');
    
        return League\Glide\ServerFactory::create([
            'source' => $filesystem->getDriver(),
            'cache' => $filesystem->getDriver(),
            'source_path_prefix' => 'path/to/source/images',
            'cache_path_prefix' => 'path/to/image/cache',
        ]);
    });
    

    Laravel 5 was also a big reason why I added the new source_path_prefix and cache_path_prefix options. Normally you would just set this when create your Flysystem objects, but since you only have one instance available in Laravel 5 you need a way to set the source and cache paths at the Server level.

    You'll also notice that I rearranged the folder structure significantly in this version as well, so there are a bunch of new class names and namespaces. This was a bit painful, but I think it was a good move thinking long term.

    Just thought I'd touch base and bring you up to speed on all this! :)

    enhancement 
    opened by reinink 8
  • S3 support

    S3 support

    Hello again! You've mentioned in a readme, that were planning at some point to add other disk drivers support, would +1 an S3 please. We have common "file uploads" going to/serving from s3, but images that require Glide cropping and so on are still on local disk, ideally would like to move all the uploads to Amazon. Not sure though about the best practices regarding cache for example. Have seen a few stackoverflow questions/discussions on having originals on s3, cache on local or disabling cache completely and just serving from s3...

    opened by artemverbo 6
  • Call to undefined method GlideImage::create()

    Call to undefined method GlideImage::create()

    Immediatly after install I get the following error when testing in my routes.

    FatalErrorException in Facade.php line 218:
    Call to undefined method Spatie\Glide\GlideImage::create()
    

    I followed the installation instructions, any idea what I might be doing wrong?

    opened by notflip 5
  • getURL and Load in v3

    getURL and Load in v3

    Hi,

    In v2 I did things like:

    return GlideImage::load($this->avatar, 
             ['w' => 100, 'h' => 100, 'fit' => 'crop'])->getURL();
    

    But I wanna upgrade to v3, but how to achieve the same? I found out that I had to add the storage_path to the load, but the getURL returns Fatal error: Call to undefined method Spatie\Glide\GlideImage::getURL()

    return GlideImage::create(storage_path('app/images/'.$this->avatar), 
         ['w' => 100, 'h' => 100, 'fit' => 'crop'])->getURL();
    

    As far I could see it wasn't possible to use load() anymore, but the docs still shows it: https://www.dropbox.com/s/3vbc6d1fd8lch2n/Schermafdruk%202016-02-12%2020.25.12.png?dl=0

    opened by Jaspur 5
  • setManipulations Watermark path

    setManipulations Watermark path

    I am trying to add a watermark to my image:

    $this->addMediaConversion('large')
        ->setManipulations(['fm' => 'jpg', 'mark' => 'watermark.png', 'markw' => '40', 'markh' => '40', 'markpad' => '15', 'markpos' => 'top-left'])
        ->performOnCollections('images');
    

    Following the Glide doc (http://glide.thephpleague.com/1.0/api/watermarks/) I added a new filesystem for watermarks, in the laravel's config/filesystems.php file.

    However, my generated thumb doesnt have any watermark on it. And there is no log error report.

    Where should I place my watermark.png file ? I tried in storage/images and storage/watermarks and even modifying 'mark' => storage_path('images/watermark.png') but I can't get it working.

    opened by philmarc 4
  • Php 7 required

    Php 7 required

    Packagists show ~14k installs for this package. I'm with a small web-app firm (4 people), and we simply have too much old sites running to port everything to php 7. We'll get there in about 1 year I guess, we have 120 sites running (low traffic).

    Our new system is built upon Laravel 5.1, and we like to keep up with new development now. However, getting our vps to php 7 is simply not an option in the nearby future.

    We really like this package, and would like to continue using it. I've read tons on the cool new stuff in 7, but for a big package breaking with many people seems like a bad plan!

    There is the option of maintaining two branches at the same time. With the Python 2/3 problems, lots of big libraries have tried really hard to be compatible with 2.X and 3.X , none of the big ones did complete dropping of 2.X

    opened by afraca 4
  • Laravel 8.x Compatibility

    Laravel 8.x Compatibility

    This is an automated pull request from Shift to update your package code and dependencies to be compatible with Laravel 8.x.

    Before merging, you need to:

    • Checkout the l8-compatibility branch
    • Review all comments for additional changes
    • Thoroughly test your package

    If you do find an issue, please report it by commenting on this PR to help improve future automation.

    opened by laravel-shift 3
Releases(3.6.2)
Owner
Spatie
Webdesign agency based in Antwerp, Belgium
Spatie
Convert image types. Take samples of pdfs or psd, do some filters as SEPIA, resizes. Save to WEBP

img2img. PHP Converter, sampler of pdfs & psd, do resizes & some filters in images as SEPIA. Save to WEBP V.1.0.3 This class in pure PHP try to manage

Rafael Martin Soto 9 Oct 23, 2022
ImageWorkshop is a PHP5.3+ library that helps you to manage images based on GD library

================================ ImageWorkshop class ================================ Summary and features Really flexible and easy-to-use PHP class t

Clément Guillemain 853 Dec 27, 2022
GifCreator is a PHP class that creates animated GIF from multiple images

================================ GifCreator ================================ GifCreator is a PHP class to create animated GIF from multiple images For

Clément Guillemain 320 Dec 15, 2022
Create images with embedded text using advanced typography

Image with Text This class makes it super easy to render images with multiple, independently styled text blocks. You can control each text block's ali

New Media Campaigns 144 Sep 7, 2022
A PHP GD + TwitterOAuth demo to dynamically generate Twitter header images and upload them via the API.

A PHP GD + TwitterOAuth demo to dynamically generate Twitter header images and upload them via the API. This enables you to build cool little tricks, like showing your latest followers or sponsors, latest content creted, a qrcode to something, a progress bar for some goal, and whathever you can think of.

Erika Heidi 172 Jan 5, 2023
Upload SVG images in Magento 2.x

Upload SVG images in Magento 2.x This extension for Magento 2 allows uploading SVG images in the following sections: wysiwyg editor in static blocks a

Magegadgets 6 Dec 23, 2022
PHP library to resize, scale and crop images.

PHP library to resize, scale and crop images.

Gumlet 1.1k Jan 3, 2023
Inline Images Protocol implementation for PHP.

Imgecho Echo the image on iTerm App using Inline Images Protocol. Installation Use Composer to install. composer require mileschou/imgecho Usage Use

MilesChou 4 May 30, 2022
The Tinify API allows you to compress and optimize WebP, JPEG and PNG images.

The Tinify API allows you to compress and optimize WebP, JPEG and PNG images. It is designed as a REST service. The client libraries in various languages make it very easy to interact with the Tinify API.

Devscast 10 May 13, 2022
The Gregwar\Image class purpose is to provide a simple object-oriented images handling and caching API

Gregwar's Image class The Gregwar\Image class purpose is to provide a simple object-oriented images handling and caching API. Installation With compos

Grégoire Passault 958 Dec 29, 2022
Simple, fast and secure archive for images

Slim Image Archive Simple*, fast and secure archive for images: Create multiple categories with multiple albums with multiple images! Manage multiple

KS 24 Oct 23, 2021
The image server plugin allows you to add responsive images via config without extra elements

Grav image server plugin adds picture tag with loading, responsive, high density images

catchIT 7 Dec 30, 2022
Create beautiful generative background images from a string. Based on jasonlong/geo_pattern

GeoPattern This is a PHP port of jasonlong/geo_pattern. Generate beautiful tiling SVG patterns from a string. The string is converted into a SHA and a

Redeye Group 106 Aug 17, 2022
Contao extension to provide the possibility of defining alternative images to be used on different output devices.

Contao Image Alternatives This extensions expands the capabilities of using responsive images with art direction in Contao. You will have the possibil

inspiredminds 6 May 30, 2022
PHP library to easily edit image with GD extension. Resize, crop, merge, draw, and many more options !

PHP Image Editor PHP library to easily edit image with GD extension. Resize, crop, merge, draw, and many more options ! ✨ Supporting ⭐ Star this repos

Franck Alary 17 Nov 13, 2022
An unofficial package maintained by Salla to help developers to implement ZATCA (Fatoora) QR code easily which required for e-invoicing

ZATCA (Fatoora) QR-Code Implementation An unofficial package maintained by Salla to help developers to implement ZATCA (Fatoora) QR code easily which

Salla 96 Dec 25, 2022
Optimize your images on the fly with Glide for Laravel.

Glide for Laravel Optimize your images on the fly with Glide for Laravel. Support us Like our work? You can support us by purchasing one of our produc

Flowframe 53 Oct 17, 2022
A simple wrapper for PHP Intervention Library to provide a more simple interface and convenient way to convert images to webp

This package is a simple wrapper for PHP Intervention Library to provide a more simple interface and convenient way to convert images to webp - next generation format - extension, and resize them to render only needed sizes.

eyad hamza 18 Jun 28, 2022
A FREE Wordpress Plugin to compress and convert images using cwebp, jpegoptim and optipng.

Squidge Is FREE WordpPress Plugin built for developers in mind compressing and convert images using jpegoptim, optipng, cwebp, and libavif. It's extre

Ainsley Clark 23 Dec 10, 2022
A web app for the resolution of a mobile game in wich you have 4 images and a list of letters, then a few boxes to fill with the word connecting the four images.

4images_1mot_solutions A web app for the resolution of a mobile game in wich you have 4 images and a list of letters, then a few boxes to fill with th

FOTSO Claude 3 Jan 13, 2022