1. Go to this page and download the library: Download isapp/laravel-imagetools library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
isapp / laravel-imagetools example snippets
use Isapp\\ImageTools\\Facades\\ImageTools;
// A string URL, or null when the source is narrower than 640px (see "Larger than the source").
$url = ImageTools::asset('resource/images/placeholder.jpg?w=640&q=75&format=webp');
use Isapp\ImageTools\Facades\ImageTools;
// Reads s3://<bucket>/assets/hero.jpg, processes it, writes the result to the
// configured output disk (image-tools.disk).
ImageTools::disk('s3')->asset('assets/hero.jpg?w=1200&format=webp');
return [
'resource/images/hero.jpg?h=630&w=1200&fit=contain&format=webp&q=82' => [
'path' => 'image-tools/hero--a1b2c3d4e5.webp',
'disk' => 'public',
// The source this file was built from, used by imagetools:regenerate.
'source' => 'resource/images/hero.jpg?w=1200&h=630&fit=contain&format=webp&q=82',
'source_disk' => null,
],
// A request larger than the source: no file, and asset() returns null.
'resource/images/icon.png?w=3840' => [
'path' => null,
'disk' => null,
'source' => 'resource/images/icon.png?w=3840',
'source_disk' => null,
],
// A media() call: the entry also records the Media key.
's3:42/slide.jpg?format=avif&w=1400' => [
'path' => 'image-tools/slide--f6e5d4c3b2.avif',
'disk' => 'public',
'source' => '42/slide.jpg?w=1400&format=avif',
'source_disk' => 's3',
'media_id' => 42,
],
];
blade
<img src="{{ ImageTools::asset('public/images/hero.jpg?w=1200&format=webp&queue=1') }}">
{{-- Generated in the request, even when the config queues: --}}
<img src="{{ ImageTools::asset('public/images/logo.png?w=200&queue=0') }}">