thapp/jmg
Larablocks Analysis
thapp/jmg has no release yet to check Laravel compatibility against.
Recommendation checks
Use with careUse with care: meets 0 of 3 checks.
- No dated releases
- 0 downloads a month (needs 10,000)
- 1 GitHub star (needs 100)
Data from Packagist and GitHub, checked by Larablocks on Nov 28, 2026.
| Install | |
|---|---|
composer require thapp/jmg:dev-processchain |
|
| PHP: | ^5.6 || ^7.0 |
| License: | MIT |
| Last Updated: | Mar 16, 2016 |
| Links: | GitHub · Packagist |
Jmg
Just In Time Image manipulation: Library for HTTP based image manipulation.
Installation
> composer composer require thapp/jmg
Run tests
> composer install
> vendor/bin/phpunit -c phpunit.xml.dist
Quick start
Using the ImageResolver class, it is easy to resolve images from parameter strings.
<?php
use Thapp\Jmg\ParamGroup;
use Thapp\Jmg\Image\Processor;
use Thapp\Jmg\Resolver\PathResolver;
use Thapp\Jmg\Resolver\LoaderReslover;
use Thapp\Jmg\Resolver\ImageResolver;
$processor = new Thapp\Jmg\Image\Processor(
new Thapp\Image\Driver\Gd\Source
);
$images = new ImageResolver($source, $pathResolver, $loaderResolver);
if ($resource = $res->resolve('images/source.jpg', ParamGroup::fromString('2/400/400/5'))) {
header('Content-Type: image/jpeg');
echo $resource->getContents();
}
Core concepts
Source loaders and resolvers
Jmg supports loading images from a variety of sources. In the example below, lets assume we have a local filesystem that hosts our images.
<?php
use Thapp\Jmg\Loader\FilesystemLoader;
use Thapp\Jmg\Resolver\LoaderReslover;
use Thapp\Jmg\Resolver\PathResolver;
$loaderResolver = new LoaderResolver;
$pathResolver = new PathResolver;
$pathResolver->add('local', __DIR__.'public/images');
$loaderResolver->add('local', new FilesystemLoader);
// tries to resolve a given prefix path;
if (!$loader === $loaderResolver->resolve('local')) // returns the FilesystemLoader {
//then error
}
if (null === $path = $pathResolver->resolve('local')) {
//then error
}
$src = $loader->load($path . '/image.jpg');
Custom loaders
You may create your own loaders, e.g. for loading images from a remote source like an Amazon s3 storage or an ftp server.
Your custom loader must implement the Thapp\Jmg\Loader\LoaderInterface or simply extend from Thapp\Jmg\Loader\AbstractLoader.
<?php
namespace Acme\Loaders;
use Thapp\Jmg\Loader\AbstractLoader
class AWSLoader extends AbstractLoader
{
/**
* @throws Thapp\Jmg\Exception\SourceLoaderException
* @return Thapp\Jmg\Resource\FileResourceInterface
*/
public function load($file)
{
//…
}
/**
* @return bool
*/
public function supports($path)
{
//…
}
}
Related Packages
Image manipulation library Lumen Framework based on Imagine and inspired by Crop...
Библиотека преображения изображений Imgso для Laravel 5, основанная на библиотек...