PHPackages                             adevendorf/craft-pretzelimage - 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. adevendorf/craft-pretzelimage

ActiveCraft-plugin

adevendorf/craft-pretzelimage
=============================

Generate image transforms upon image request in realtime -- load via web server directly as public files, or combine with a CDN.

v3.0.0(1y ago)091mitPHP

Since Dec 12Pushed 1y ago1 watchersCompare

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

READMEChangelogDependencies (2)Versions (36)Used By (0)

Pretzel Image
=============

[](#pretzel-image)

Pretzel Image generates image transforms at browser request time. The resulting image is stored in a public folder. Because the controller route is the same as the actual file, we let the web server serve the actual file before passing it off to the plugin to process the request.

The generated file can be deleted from the server at any time because it will just be recreated if it no longer exists.

The images are organized into a two character directory, then asset ID subdirectory. This is done to mitigate the possibility, of too many directories/files in a single folder.

The original purpose of this plugin is to place a CDN in front of the site so that these generated images would only live a short time on the actual Craft CMS server.

In practice, this plugin works well for multi-instance Craft CMS setups on high traffic sites. By utilizing an NFS server, you can reuse the same generated images between all the servers, then load balance the CMS for image generation.

Configuration
-------------

[](#configuration)

Pretzel should work out of the box, but you can customize it.

### PRETZEL\_PATH

[](#pretzel_path)

By default images are stored in the @web/\_imgs directory, but you can override it in your .env file with PREZTEL\_PATH

> PRETZEL\_PATH="images"

### PRETZEL\_HOSTS

[](#pretzel_hosts)

Pretzel will allow images to be generated by any host when in Craft CMS is in Dev Mode, otherwise it will only accept referrers from the current defined site url, or hosts you define in:

> PRETZEL\_HOSTS="[www.somesite.com,help.somesite.com](http://www.somesite.com,help.somesite.com)"

How to use
----------

[](#how-to-use)

There are 3 arguments you pass into a *url* method.

1. The Craft CMS Asset
2. Object (or Array) of transformations
3. *(Optional)* Default object of transformations that will be applied to all images

```
craft.pretzel.url(asset, { width: 100, height: 50 }, { position: asset.getFocalPoint() });
```

#### Twig

[](#twig)

```
{% set asset = craft.assets().one() %}

{% set images = craft.pretzel.url(asset, [
    { width: 600, ratio: 1/1},
    { width: 1024, ratio: 16/9 }
], { position:asset.getFocalPoint()|default('50% 50%') }) %}

```

If multiple transformation configurations are passed, an array is returned instead of a URL string.

#### PHP (Element API)

[](#php-element-api)

```
use adevendorf\pretzelimage\Plugin;

$asset = $entry->image->one();
$image = Plugin::$plugin->pretzelService->url($asset, [
  'width' => 600, 'height' => 360, 'position' => $asset->getFocalPoint()
]);
```

Image Options
-------------

[](#image-options)

width

---

height:

---

ratio

---

position: 50-50 (default)

---

mode: crop (default), fill

Requirements
------------

[](#requirements)

This plugin requires Craft CMS 4 or later, and PHP 8.0.2 or later.

### TODO

[](#todo)

- Automatically remove old images from the file space based on age of the file.
- Provide an option to never store the generated file.
- Allow the definition of the CDN URL instead of using the Craft CMS Site URL.
- Test GraphQL Support

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance41

Moderate activity, may be stable

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~15 days

Recently: every ~1 days

Total

32

Last Release

425d ago

Major Versions

v1.0.11 → v2.0.02024-06-11

v2.0.0 → v3.0.02024-06-11

v1.0.13 → v2.0.12025-02-14

v1.0.14 → v2.1.12025-02-15

v1.3.1 → v2.3.02025-03-10

### Community

Maintainers

![](https://www.gravatar.com/avatar/6286904b43ed92035dff3af48fc288bdfd2747272767caf9a224187f2819262f?d=identicon)[adevendorf](/maintainers/adevendorf)

---

Top Contributors

[![adevendorf](https://avatars.githubusercontent.com/u/1859922?v=4)](https://github.com/adevendorf "adevendorf (1 commits)")

---

Tags

imagesassetscraftcms

### Embed Badge

![Health badge](/badges/adevendorf-craft-pretzelimage/health.svg)

```
[![Health](https://phpackages.com/badges/adevendorf-craft-pretzelimage/health.svg)](https://phpackages.com/packages/adevendorf-craft-pretzelimage)
```

###  Alternatives

[spicyweb/craft-embedded-assets

Manage YouTube videos, Instagram photos and more as first class assets

172435.6k9](/packages/spicyweb-craft-embedded-assets)[benjamminf/craft-embedded-assets

Manage YouTube videos, Instagram photos and more as first class assets

17113.1k](/packages/benjamminf-craft-embedded-assets)[intoeetive/protectedlinks

Secure &amp; restricted files download

156.1k](/packages/intoeetive-protectedlinks)

PHPackages © 2026

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