PHPackages                             imponeer/smarty-image - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Image &amp; Media](/categories/media)
4. /
5. imponeer/smarty-image

ActiveLibrary[Image &amp; Media](/categories/media)

imponeer/smarty-image
=====================

Smarty plugin that adds some image related template syntax enchantments

v3.1.2(5mo ago)220.6k↓33.3%MITPHPPHP ^8.3CI failing

Since Feb 3Pushed 1mo ago2 watchersCompare

[ Source](https://github.com/imponeer/smarty-image)[ Packagist](https://packagist.org/packages/imponeer/smarty-image)[ RSS](/packages/imponeer-smarty-image/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (10)Versions (16)Used By (0)

[![License](https://camo.githubusercontent.com/49bb0b8513d617ef25a34b65aabb0302bfb7599b9d04625c3878712a43d11e72/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f696d706f6e6565722f736d617274792d696d6167652e737667)](LICENSE) [![GitHub release](https://camo.githubusercontent.com/5dcfe6dbafd32f5a938c741bcac453dd92c129d445ea2544d92fc68b63f43ca9/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f696d706f6e6565722f736d617274792d696d6167652e737667)](https://github.com/imponeer/smarty-image/releases) [![PHP](https://camo.githubusercontent.com/c074309438b2c78d4baf3c3549b4226759abf6df32ae7809b544d60cbe3482aa/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f696d706f6e6565722f736d617274792d696d6167652e737667)](http://php.net) [![Packagist](https://camo.githubusercontent.com/9ffa607177b1de3c10d510fa7d5a7764ed3c922a2178a9181a941d22358e3d93/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f696d706f6e6565722f736d617274792d696d6167652e737667)](https://packagist.org/packages/imponeer/smarty-image) [![Smarty version requirement](https://camo.githubusercontent.com/a6182c6b462459d357c1ec414e49c3aa71fa0dcc6adf329449f1af3571b71c5f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f696d706f6e6565722f736d617274792d696d6167652f736d61727479253246736d61727479)](https://smarty-php.github.io)

Smarty Image
============

[](#smarty-image)

A modern [Smarty](https://smarty.net) extension that provides image resizing capabilities with built-in caching. This extension allows you to resize images directly from your Smarty templates using the `resized_image` function.

Installation
------------

[](#installation)

To install and use this package, we recommend to use [Composer](https://getcomposer.org):

```
composer require imponeer/smarty-image
```

Otherwise, you need to include manually files from `src/` directory.

Setup
-----

[](#setup)

### Basic Setup

[](#basic-setup)

For Smarty v5 and newer, use the new extension system:

```
$smarty = new \Smarty\Smarty();
// For $psrCacheAdapter value use PSR-6 cache adapter, for example Symfony\Component\Cache\Adapter\ArrayAdapter
$smarty->addExtension(
    new \Imponeer\Smarty\Extensions\Image\SmartyImageExtension($psrCacheAdapter)
);
```

For older Smarty use [v2.0 version of this plugin](https://github.com/imponeer/smarty-image/tree/v2.0.2).

### Using with Symfony Container

[](#using-with-symfony-container)

When using Symfony's dependency injection container, you can register the extension as a service:

```
# config/services.yaml
services:
    Imponeer\Smarty\Extensions\Image\SmartyImageExtension:
        arguments:
            $cache: '@cache.app'
        tags:
            - { name: 'smarty.extension' }
```

Then inject it into your Smarty instance:

```
// In your controller or service
public function __construct(
    private Smarty $smarty,
    private SmartyImageExtension $imageExtension
) {
    $this->smarty->addExtension($this->imageExtension);
}
```

### Using with PHP-DI

[](#using-with-php-di)

With PHP-DI container, configure the extension in your container definitions:

```
use Psr\Cache\CacheItemPoolInterface;
use Imponeer\Smarty\Extensions\Image\SmartyImageExtension;
use Symfony\Component\Cache\Adapter\FilesystemAdapter;

return [
    CacheItemPoolInterface::class => \DI\create(FilesystemAdapter::class),
    SmartyImageExtension::class => \DI\create()
        ->constructor(\DI\get(CacheItemPoolInterface::class)),

    Smarty::class => \DI\factory(function (SmartyImageExtension $imageExtension) {
        $smarty = new Smarty();
        $smarty->addExtension($imageExtension);
        return $smarty;
    })
];
```

### Using with League Container

[](#using-with-league-container)

With League Container, register the services like this:

```
use League\Container\Container;
use Psr\Cache\CacheItemPoolInterface;
use Symfony\Component\Cache\Adapter\ArrayAdapter;
use Imponeer\Smarty\Extensions\Image\SmartyImageExtension;

$container = new Container();

$container->add(CacheItemPoolInterface::class, ArrayAdapter::class);
$container->add(SmartyImageExtension::class)
    ->addArgument(CacheItemPoolInterface::class);

$container->add(Smarty::class)
    ->addMethodCall('addExtension', [SmartyImageExtension::class]);
```

Usage
-----

[](#usage)

To resize images from Smarty templates, you can use the `resized_image` function:

```
  {resized_image file="/images/image.jpg" height=70}
```

This function supports such arguments:

ArgumentRequiredDefault valueDescription`file`yesImage file to resize`width`if `height` is not specifiedResized image width`height`if `width` is not specifiedResized image height`fit`no`outside`Method used for resize. Supported `fill`, `inside`, `outside``href` or `link`noif specified and `return` is set to `image`, will output generated HTML as image with link to this specific location`basedir`no$\_SERVER\['DOCUMENT\_ROOT'\]Base dir where to look for image files`return`no`image`Returns result as HTML tag if value is `image`, or as resized image URI if value is `url`.All extra arguments will be rendered into image tag, if return mode is `image`.

Development
-----------

[](#development)

This project uses modern PHP development tools and practices:

### Running Tests

[](#running-tests)

```
composer test
```

### Code Style

[](#code-style)

The project follows PSR-12 coding standards. Check code style with:

```
composer phpcs
```

Fix code style issues automatically:

```
composer phpcbf
```

### Static Analysis

[](#static-analysis)

Run PHPStan for static code analysis:

```
composer phpstan
```

Documentation
-------------

[](#documentation)

API documentation is automatically generated and available in the [project's wiki](https://github.com/imponeer/smarty-image/wiki). For more detailed information about the classes and methods, please refer to the [project wiki](https://github.com/imponeer/smarty-image/wiki).

How to contribute?
------------------

[](#how-to-contribute)

We welcome contributions! If you want to add functionality or fix bugs:

1. Fork the repository
2. Create a feature branch from `main`
3. Make your changes following the coding standards
4. Add or update tests as needed
5. Run the test suite to ensure everything works
6. Submit a pull request with a clear description of your changes

For bug reports or feature requests, please use the [issues tab](https://github.com/imponeer/smarty-image/issues) and provide as much detail as possible.

###  Health Score

53

—

FairBetter than 97% of packages

Maintenance81

Actively maintained with recent releases

Popularity27

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity76

Established project with proven stability

 Bus Factor1

Top contributor holds 64.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~135 days

Recently: every ~221 days

Total

14

Last Release

168d ago

Major Versions

v1.1.5 → v2.0.02023-02-01

v2.0.2 → v3.0.02025-06-16

PHP version history (3 changes)v1.0.0PHP &gt;=7.1

v2.0.0PHP ^7.3|^8.0

v3.0.0PHP ^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/dba53e399a507d1f60626164c8b1e340a5cc0dc4f0637f4c6aaff8fc239fdaee?d=identicon)[fiammybe](/maintainers/fiammybe)

![](https://www.gravatar.com/avatar/7255f306e0ca27292c50cdd9644c1c04e0d7b0f54bf35e0cdd79dc55c83b4923?d=identicon)[MekDrop](/maintainers/MekDrop)

![](https://www.gravatar.com/avatar/79009323fafcd4974bb1713b12eea0a610f01c4fb21cc5e85d446c4cb66453d4?d=identicon)[skenow](/maintainers/skenow)

---

Top Contributors

[![MekDrop](https://avatars.githubusercontent.com/u/342641?v=4)](https://github.com/MekDrop "MekDrop (55 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (25 commits)")[![Codex](https://avatars.githubusercontent.com/in/2248422?v=4)](https://github.com/Codex "Codex (2 commits)")[![fiammybe](https://avatars.githubusercontent.com/u/3736946?v=4)](https://github.com/fiammybe "fiammybe (2 commits)")[![mend-bolt-for-github[bot]](https://avatars.githubusercontent.com/in/16809?v=4)](https://github.com/mend-bolt-for-github[bot] "mend-bolt-for-github[bot] (1 commits)")

---

Tags

hacktoberfestimage-processingsmartysmarty-extensionsmarty-pluginsimageimage processingsmartysmarty-plugins

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/imponeer-smarty-image/health.svg)

```
[![Health](https://phpackages.com/badges/imponeer-smarty-image/health.svg)](https://phpackages.com/packages/imponeer-smarty-image)
```

###  Alternatives

[league/glide

Wonderfully easy on-demand image manipulation library with an HTTP based API.

2.6k51.2M116](/packages/league-glide)[intervention/image-laravel

Laravel Integration of Intervention Image

1536.5M102](/packages/intervention-image-laravel)[bkwld/croppa

Image thumbnail creation through specially formatted URLs for Laravel

510496.0k23](/packages/bkwld-croppa)[lasserafn/php-initial-avatar-generator

A package to generate avatars with initials for PHP

4374.2M13](/packages/lasserafn-php-initial-avatar-generator)[media-alchemyst/media-alchemyst

An Object Oriented wrapper for easy multimedia conversion, based on Imagine, FFMpeg, SwfTools, Unoconv and other libs

65216.4k1](/packages/media-alchemyst-media-alchemyst)[joshembling/image-optimizer

Optimize your Filament images before they reach your database.

111145.4k12](/packages/joshembling-image-optimizer)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
