1. Go to this page and download the library: Download survos/imgproxy-bundle 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/ */
survos / imgproxy-bundle example snippets
use Survos\ImgproxyBundle\Service\ImgproxyUrlBuilder;
class MyService
{
public function __construct(private ImgproxyUrlBuilder $imgproxy) {}
public function example(string $sourceUrl): void
{
// Preset-based (recommended)
$url = $this->imgproxy->resizePreset($sourceUrl, 'ai'); // 512×512 for AI vision
$url = $this->imgproxy->resizePreset($sourceUrl, 'thumb'); // 300×300
// Convenience shorthand
$url = $this->imgproxy->aiThumbnail($sourceUrl); // equivalent to resizePreset('ai')
$url = $this->imgproxy->thumbnail($sourceUrl, 256); // arbitrary square size
// Explicit dimensions
$url = $this->imgproxy->resize($sourceUrl, 800, 600, 'fill');
}
}
// Fetch metadata (signed URL is built + fetched + JSON-decoded for you)
$meta = $this->imgproxy->info($sourceUrl, ['size', 'format', 'dimensions']);
// => ['size' => 123456, 'format' => 'jpeg', 'mime_type' => 'image/jpeg',
// 'width' => 7360, 'height' => 4912, 'orientation' => 1]
// Image classification (PRO ML) — top-K classes with confidence scores.
$result = $this->imgproxy->classify($sourceUrl, topK: 5);
// => ['classification' => [['class_id' => 90, 'name' => 'Cat', 'confidence' => 0.97]], ...]
// optionally restrict to a known class list:
$result = $this->imgproxy->classify($sourceUrl, 5, ['cat', 'dog', 'bird']);
// Object detection (PRO ML) — bounding boxes (relative coords) + confidence.
$objects = $this->imgproxy->detectObjects($sourceUrl);
// Just build the signed /info URL (no fetch):
$url = $this->imgproxy->infoUrl($sourceUrl, ['dimensions', 'blurhash:4:3']);
// list of tokens — a valueless token gets an implicit ":1"
['dimensions', 'blurhash:4:3', 'classify:5:cat:dog']
// ^ becomes dimensions:1
// key => value pairs (bool → :1/:0, scalar → :value)
['palette' => 8, 'detect_objects' => true, 'size' => false]
// a raw option path string (passed through as-is)
'dimensions:1/bh:4:3'
use Survos\ImgproxyBundle\Contract\AiThumbnailProviderInterface;
class MyMedia implements AiThumbnailProviderInterface
{
public function getAiSmallUrl(): string
{
// return a pre-computed URL, or generate via imgproxy, liip, etc.
return $this->smallUrl ?? $this->sourceUrl;
}
}