codewithkyle/jitter-core

An Imgix inspired image transformation library.

2.0.2 2024-10-09 17:07 UTC

This package is auto-updated.

Last update: 2024-11-09 17:19:42 UTC


README

Jitter is an image transformation library with an API is based on Imgix. This library was created to be a simple and free alternative to an Imgix style service. It does not and will not have all the bells and whistles that other services/libraries offer. If you need something more advanced besides basic image transformations I suggest you pay for Imgix.

Requirements

This library requires PHP 7.2 or later and ImageMagick.

Installation

# Install the library via composer
composer require codewithkyle/jitter-core

# Optional webp support (recommended)
sudo apt install webp

Using Jitter

Transforming images:

use codewithkyle\JitterCore\Jitter;

class ImageController
{
    public function transformImage()
    {
        $imageFilePath = "./image.jpg"; // copy of source image (will be overwritten)
        $params = ["w" => 320, "ar" => "1:1", "fm" => "jpg"]; // See transformation parameter table below for more options

        $transformSettings = Jitter::BuildTransform($params); // Transform settings can be hashed with the base image's indentifier when caching
        Jitter::TransformImage($imageFilePath, $transformSettings); // Manipulates and overwrites the image located at $imageFilePath

        // Optional Next Steps:
        // Save $imageFilePath a cloud provider (such as S3)
    }
}

Transformation parameters:

The auto format type will return a webp image when the server can generate the format and the client's browser supports the format.