1. Go to this page and download the library: Download wa72/adaptimage 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/ */
wa72 / adaptimage example snippets
use Wa72\AdaptImage\ImageResizeDefinition;
use Wa72\AdaptImage\ImagineFilter\Sharpen;
$sizes = array(
ImageResizeDefinition::create(1600, 1200),
ImageResizeDefinition::create(1280, 1024),
ImageResizeDefinition::create(768, 576),
ImageResizeDefinition::create(1024, 768)->addFilter(new Sharpen() // example with additional sharpen filter
);
use Wa72\AdaptImage\Output\OutputPathGeneratorBasedir;
$cachedir = __DIR__ . '/cache';
$output_path_generator = new OutputPathGeneratorBasedir($cachedir);
use Wa72\AdaptImage\AdaptiveImageResizer;
use Wa72\AdaptImage\ThumbnailGenerator;
use Imagine\Imagick\Imagine; // or some other Imagine version
$imagine = new Imagine();
$thumbnail_generator = new ThumbnailGenerator($imagine, $output_path_generator, 150, 150, 'inset');
$resizer = new AdaptiveImageResizer($imagine, $output_path_generator, $sizes);
use Wa72\AdaptImage\ImageFileInfo;
$image = ImageFileInfo::createFromFile('/path/to/original/image');
$thumbnail = $thumbnail_generator->thumbnail(true, $image);
$client_screen_width = 1024; // typically you get this value from a cookie
$resized_image = $resizer->resize(true, $image, $client_screen_width);
$response = new Symfony\Component\HttpFoundation\BinaryFileResponse($resized_image->getPathname());
$response->prepare($request);
return $response;
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.