Convert Figma logo to code with AI

thephpleague logoglide

Wonderfully easy on-demand image manipulation library with an HTTP based API.

2,547
198
2,547
43

Top Related Projects

4,415

PHP Object Oriented image manipulation library

Symfony Bundle to assist in image manipulation using the imagine library

Quick Overview

Glide is a PHP image manipulation library built on top of Intervention Image. It provides a simple, fluent API for performing common image operations like resizing, cropping, and applying filters. Glide is designed to be easy to use and integrate with various storage systems and HTTP libraries.

Pros

  • Simple and intuitive API for image manipulation
  • Supports various image formats (JPEG, PNG, GIF, WebP, AVIF)
  • Integrates well with different storage systems (local, S3, etc.)
  • Offers on-the-fly image processing through URL-based API

Cons

  • Requires GD or Imagick PHP extensions
  • Limited advanced image manipulation features compared to more specialized libraries
  • Performance may be slower for complex operations compared to native image processing tools

Code Examples

  1. Basic image resizing:
use League\Glide\ServerFactory;

$server = ServerFactory::create([
    'source' => 'path/to/source/folder',
    'cache' => 'path/to/cache/folder',
]);

$server->outputImage('image.jpg', ['w' => 300, 'h' => 200]);
  1. Applying filters and effects:
$server->outputImage('image.jpg', [
    'w' => 400,
    'filt' => 'sepia',
    'blur' => 5,
]);
  1. Generating a signed URL for secure image manipulation:
use League\Glide\Signatures\SignatureFactory;

$factory = SignatureFactory::create('your-signing-key');
$params = ['w' => 300, 'h' => 200, 'fit' => 'crop'];
$url = $factory->getUrl('image.jpg', $params);

Getting Started

  1. Install Glide via Composer:
composer require league/glide
  1. Set up a basic Glide server:
use League\Glide\ServerFactory;

$server = ServerFactory::create([
    'source' => 'path/to/source/images',
    'cache' => 'path/to/cache/folder',
]);

// Output an image
$server->outputImage('image.jpg', ['w' => 300, 'h' => 200]);
  1. Use Glide in your application to manipulate and serve images as needed.

Competitor Comparisons

4,415

PHP Object Oriented image manipulation library

Pros of Imagine

  • More flexible and feature-rich image manipulation library
  • Supports a wider range of image processing operations
  • Provides a consistent interface for various image processing backends (GD, Imagick, Gmagick)

Cons of Imagine

  • Requires more setup and configuration compared to Glide
  • Less optimized for on-the-fly image processing and serving
  • May have a steeper learning curve for basic image operations

Code Comparison

Glide (simple image resize):

$server = League\Glide\ServerFactory::create([
    'source' => 'path/to/source/folder',
    'cache' => 'path/to/cache/folder',
]);
$server->outputImage('image.jpg', ['w' => 300, 'h' => 200]);

Imagine (simple image resize):

$imagine = new Imagine\Gd\Imagine();
$image = $imagine->open('image.jpg');
$size = new Imagine\Image\Box(300, 200);
$image->resize($size)->save('resized_image.jpg');

Both libraries offer image manipulation capabilities, but Glide is more focused on serving images on-the-fly with a simple API, while Imagine provides a more comprehensive set of image processing tools. Glide is better suited for quick implementation of image resizing and serving, whereas Imagine offers more flexibility for complex image manipulations across different backends.

Symfony Bundle to assist in image manipulation using the imagine library

Pros of LiipImagineBundle

  • Seamless integration with Symfony framework
  • Extensive caching mechanisms for improved performance
  • Supports a wide range of filters and effects out-of-the-box

Cons of LiipImagineBundle

  • More complex setup and configuration compared to Glide
  • Heavier dependency footprint
  • Steeper learning curve for non-Symfony developers

Code Comparison

LiipImagineBundle:

liip_imagine:
    filter_sets:
        my_thumb:
            quality: 75
            filters:
                thumbnail: { size: [120, 90], mode: outbound }

Glide:

$server = League\Glide\ServerFactory::create([
    'source' => 'path/to/source/folder',
    'cache' => 'path/to/cache/folder',
]);

$server->outputImage('image.jpg', ['w' => 120, 'h' => 90, 'fit' => 'crop']);

Summary

LiipImagineBundle excels in Symfony environments, offering robust caching and a wide array of filters. However, it comes with a steeper learning curve and more complex setup. Glide, on the other hand, provides a simpler, more straightforward approach to image manipulation, making it easier to integrate into various PHP projects. The choice between the two depends on your project's framework, complexity requirements, and developer familiarity with Symfony.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Glide

Latest Version Software License Build Status Code Coverage Total Downloads Source Code Author Author

Glide is a wonderfully easy on-demand image manipulation library written in PHP. Its straightforward API is exposed via HTTP, similar to cloud image processing services like Imgix and Cloudinary. Glide leverages powerful libraries like Intervention Image (for image handling and manipulation) and Flysystem (for file system abstraction).

© Photo Joel Reynolds

© Photo Joel Reynolds

Highlights

  • Adjust, resize and add effects to images using a simple HTTP based API.
  • Manipulated images are automatically cached and served with far-future expires headers.
  • Create your own image processing server or integrate Glide directly into your app.
  • Supports both the GD library and the Imagick PHP extension.
  • Supports many response methods, including PSR-7, HttpFoundation and more.
  • Ability to secure image URLs using HTTP signatures.
  • Works with many different file systems, thanks to the Flysystem library.
  • Powered by the battle tested Intervention Image image handling and manipulation library.
  • Framework-agnostic, will work with any project.
  • Composer ready and PSR-2 compliant.

Documentation

Full documentation can be found at glide.thephpleague.com.

Installation

Glide is available via Composer:

$ composer require league/glide

Testing

Glide has a PHPUnit test suite. To run the tests, run the following command from the project folder:

$ phpunit

Contributing

Contributions are welcome and will be fully credited. Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email jonathan@reinink.ca instead of using the issue tracker.

Credits

License

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