1. Go to this page and download the library: Download intervention/image-tempest 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/ */
intervention / image-tempest example snippets
use Intervention\Image\Drivers\Gd\Driver as GdDriver;
use Intervention\Image\Tempest\Config as ImageConfig;
return new ImageConfig(
/*
|--------------------------------------------------------------------------
| Image Driver
|--------------------------------------------------------------------------
|
| Intervention Image supports “GD Library” and “Imagick” to process images
| internally. Depending on your PHP setup, you can choose one of them.
|
| Included options:
| - \Intervention\Image\Drivers\Gd\Driver::class
| - \Intervention\Image\Drivers\Imagick\Driver::class
| - \Intervention\Image\Drivers\Vips\Driver::class
*/
driver: \Tempest\env('IMAGE_DRIVER', GdDriver::class),
/*
|--------------------------------------------------------------------------
| Configuration Options
|--------------------------------------------------------------------------
|
| These options control the behavior of Intervention Image.
|
| - "autoOrientation" controls whether an imported image should be
| automatically rotated according to any existing Exif data.
|
| - "decodeAnimation" decides whether a possibly animated image is
| decoded as such or whether the animation is discarded.
|
| - "backgroundColor" Defines the default background & blending color.
|
| - "strip" controls if meta data like exif tags should be removed when
| encoding images.
*/
autoOrientation: true,
decodeAnimation: true,
backgroundColor: 'ffffff',
strip: false,
);
use Intervention\Image\Format;
use Intervention\Image\Interfaces\ImageManagerInterface;
use Tempest\Router\Get;
use Tempest\View\View;
use function Tempest\View\view;
final readonly class HomeController
{
public function __construct(private ImageManagerInterface $imageManager)
{
//
}
#[Get(uri: '/')]
public function __invoke(): View
{
// process image
$image = $this->imageManager
->decode('./example.jpg')
->scale(height: 300)
->encodeUsingFormat(Format::WEBP);
return view('./home.view.php', dataUri: $image->toDataUri());
}
}
bash
php tempest install image
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.