Skip to content

Getting started

Now it's time to test your first image transformation!

Use the following URL format to transform your images:

http://<domain>/<route-prefix>/<source-directory>/<options>/<path-to-your-image<.jpg|.jpeg|.png|.gif|.webp>>

TIP

You can omit the <source-directory> part if you have set a default source directory in the configuration file.

For example:

http://localhost:8000/image-transform/width=250,quality=80,format=webp/foo/bar/example.jpg

With a source-directory, respectively:

http://localhost:8000/image-transform/images/width=250,quality=80,format=webp/foo/bar/example.jpg

Programmatic URL Generation

While you can construct URLs manually when you need it, the package provides convenient methods to generate transformation URLs programmatically using the ImageTransformUrl facade.

Use the make() method to generate regular transformation URLs:

php
use AceOfAces\LaravelImageTransformUrl\Facades\ImageTransformUrl;

// Generate a URL with array options
$url = ImageTransformUrl::make(
    'foo/example.jpg',
    ['width' => 250, 'quality' => 80, 'format' => 'webp'],
    'images'
);

// Generate a URL with string options
$url = ImageTransformUrl::make(
    'foo/example.jpg',
    'width=250,quality=80,format=webp',
    'images'
);

// Use default source directory (omit the third parameter)
$url = ImageTransformUrl::make(
    'foo/example.jpg',
    ['width' => 250, 'quality' => 80]
);

The url() method is also available as an alias for make():

php
$url = ImageTransformUrl::url('img/example.jpg', ['width' => 250]);

INFO

The facade also provides methods for generating signed URLs.

Released under the MIT License.