Download the PHP package spacecatninja/ai-image-editor without Composer

On this page you can find all versions of the php package spacecatninja/ai-image-editor. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package ai-image-editor

AI Image Editor for Craft CMS

Edit and generate image assets in the Craft CMS control panel using natural language, powered by AI.

Open any image asset and tell the editor what you want in plain words — "make the background white", "remove the coffee cup", "make it look like golden hour" — then iterate in a chat-style loop until it's right and save the result, either as a new asset or back over the original. Need an image that doesn't exist yet? Describe it and generate one from scratch. No fixed one-click filters, no round-trips to a desktop editor, no leaving Craft.

Requirements

Installation

To install the plugin, either install it from the Plugin Store, or follow these instructions:

  1. Install with Composer via composer require spacecatninja/ai-image-editor from your project directory.
  2. Install the plugin in the Craft Control Panel under Settings → Plugins, or from the command line via php craft plugin/install ai-image-editor.
  3. For the plugin work, you need to configure at least one driver and verify the connection with php craft ai-image-editor/test-connection. But first, read on!

Highlights

How it works

Generating new images

Besides editing existing assets, the plugin can create images from scratch. A Generate button appears next to the upload button on asset indexes (for users who can save assets in the volume) and inside asset selection modals. It opens the same editor without a source image: describe what you want, iterate in drafts, and accept to save. Generated assets land in the folder that was selected in the index, named after an AI description of the image (e.g. golden-retriever-on-a-beach.png), falling back to the first prompt. Since there is no original, only "Save as a new asset" is offered.

Reducing content drift

Generative editing can change more than you asked for. The plugin does several things to keep edits faithful:

If simple edits still drift, you can change to more advanced models or adjust the fidelity knobs per driver (Gemini's 'thinkingLevel', OpenAI's quality, FLUX's safetyTolerance, to name a few).

Drivers

Four drivers ship with the plugin, selected with the driver setting:

The gemini, openai and grok drivers also handle the analysis tasks (focal point detection, descriptive filenames) with their provider's vision models, configurable via each driver's analysisModel key. flux has no vision model, so it relies on analysisDriver (below).

Additional drivers can be registered by other plugins through the EVENT_REGISTER_EDIT_DRIVERS event (see Extending). They read their own configuration from driverConfig[handle], so a third-party driver gets typed-free settings without touching the core config, and the simplest ones can extend spacecatninja\aiimageeditor\drivers\BaseEditDriver to inherit config reading, credentials, prompt building, and the analysis wrappers.

Configuration

There is no control panel settings screen. All configuration is done in config/ai-image-editor.php, using Craft's standard multi-environment config format:

Root settings

The root of the config holds the driver selectors and cross-cutting settings; each driver's own settings live in its driverConfig block (below).

Setting Default Description
driver (required) The edit driver to use: gemini, openai, flux or grok. No default — each driver needs its own API key, so you must pick one. Additional drivers can be registered by other plugins/modules.
analysisDriver null The driver used for analysis tasks (focal point detection, descriptive filenames), when it should differ from the edit driver. Null uses the edit driver. Set this to give an edit driver without a vision model (e.g. the FLUX driver) working analysis via a provider that has one.
workingResolution '1K' Resolution tier used during the chat loop. Kept low to make iterating cheap and fast. Overridable per driver in driverConfig.
finalResolution '2K' The default resolution tier for the final result, switchable per session in the editor. Overridable per driver in driverConfig.
maxResolution null Caps the resolution tiers offered in the editor (values 512, 1K, 2K, 4K), e.g. '2K' to hide a driver's 4K option. Null exposes every tier the driver supports. Overridable per driver in driverConfig.
finalizePrompt null Overrides the prompt used for the finalize regeneration step.
preserveInstructions null Overrides the content-preservation instructions appended to prompts when the "Precise edits" toggle is on. Null uses the driver's default text.
autoFocalPoint true Automatically detect and set a focal point on saved results that don't have one, as part of the save.
descriptiveFilenames true Name generated images after an AI description of the image. When disabled (or when analysis fails), the first prompt is used instead.
aiGeneratedField null Handle of a boolean/lightswitch field on your asset volumes that is switched on when an asset is edited or generated with AI. Use it to mark AI-edited images (e.g. for disclosure requirements); how you surface that is up to you.
presets [] Quick-action chips shown in the editor composer for common edits. An array of entries, each with a label, a prompt, and an optional precise boolean (see below).
requestTimeout 120 Timeout in seconds for provider API requests.
purgeSessionsAfterHours 48 Abandoned sessions and their temp files are purged after this many hours.
maxRequestsPerMinute 20 Per-user cap on edit, generate, and finalize requests, a safety limit against runaway retry loops running up provider costs. Set to 0 to disable the throttle.

Quick actions (presets)

Presets are one-click chips shown above the composer for common edits. Each entry needs a label and a prompt; precise is optional and overrides the "Precise edits" toggle for that action (use true for faithful edits like background removal, leave it off for creative restyles). Clicking a chip runs a normal edit turn with that prompt, and leaves any text you've typed untouched.

Per-driver settings (driverConfig)

driverConfig is keyed by driver handle. Only the keys you set override that driver's defaults, so a block with just apiKey is enough to get started. Any driver, bundled or third-party, reads its config from here. The overridable root settings can also be set here to override their global value for a single driver (see the last three rows).

Key Drivers Default Description
apiKey all null The provider's API key. Reference an environment variable, never commit the key itself.
defaultModel all driver's first model The default model for new sessions, switchable per session in the editor.
analysisModel all driver's default The model used for analysis tasks. Must be a model this driver offers.
quality openai 'auto' The OpenAI quality level, its main fidelity/cost knob: auto, low, medium or high.
thinkingLevel gemini null Reasoning depth: minimal or high. Higher improves instruction adherence on complex edits, at the cost of latency.
outputFormat openai, flux source image's format The output image format, selectable per session in the editor (defaulting to the source image's format). This config key sets the fallback when no format is selected. Supported: png, jpeg, webp (Gemini: jpeg only, so no picker is shown; Grok: not supported, format is API-chosen).
safetyTolerance flux 2 Content-moderation strictness, 0 (strict) to 5 (permissive).
workingResolution all root workingResolution ('1K') Overrides the root workingResolution for this driver — the resolution tier used during the chat loop.
finalResolution all root finalResolution ('2K') Overrides the root finalResolution for this driver — the default tier for the final result.
maxResolution all root maxResolution (null) Overrides the root maxResolution for this driver — caps the resolution tiers offered in the editor (512, 1K, 2K, 4K).

After configuring, verify the setup from the command line:

Splitting analysis from editing

Analysis (focal point detection, descriptive filenames) needs a vision-language model, which not every image-editing provider has. By default it runs on the same provider as editing, but the analysisDriver setting decouples them: set driver to an edit-only provider and analysisDriver to one with a vision model, and analysis still works. For example, the FLUX driver has no vision model, so pair it with Gemini:

When analysisDriver names a different provider, remember it needs its own API key in its driverConfig block. php craft ai-image-editor/test-connection verifies both providers.

Marking AI-generated content

A growing number of jurisdictions require content that was generated or manipulated by AI to be disclosed as such. The EU AI Act's transparency obligations (Article 50), China's labeling rules for AI-generated content, and a wave of US state laws (such as California's AI Transparency Act) are all examples, with more on the way. What must be marked, how, and from when varies by jurisdiction and by how the image is used — so treat the field below as a building block, not legal advice. Whether and how you need to disclose is your responsibility to determine, ideally with counsel; the plugin does not make your site compliant on its own.

The aiGeneratedField setting gives you that building block. Point it at the handle of a lightswitch (boolean) field in your asset volumes' field layouts, and the plugin switches it on for every asset it edits or generates — including originals replaced in place via Save. Because it's an ordinary Craft field, the flag is durable, queryable, and yours to act on however the rules require, for example:

The plugin only ever flips the field on; how it's surfaced, exported, enforced, or combined with other signals is entirely up to you.

Burning in a visible watermark. When you need a watermark composited into the pixels rather than a separate on-page label, Imager X can add one as part of a transform via its watermark parameter — a watermark image plus width/height, and optional position, opacity, and blendMode. Drive it off the aiGeneratedField flag so only AI-generated assets are marked (assuming the field's handle is isAiGenerated):

Imager X watermarking runs on the local GD/Imagick transformer.

Craft Cloud and ephemeral filesystems

An edit session spans several requests (each turn, finalize, and save is a separate request), so the working images have to survive between them. The plugin keeps them in Craft's temporary filesystem (craft\fs\Temp), resolved through the container — so on Craft Cloud they're stored in the environment's private, object-storage-backed temp area, and on a load-balanced setup they're shared across instances. Nothing is written to a hardcoded local path, and this storage is not an asset volume filesystem, so a volume re-index never picks up the transient files.

These files are genuinely temporary: they're removed as soon as a session is finalized, discarded, or purged (purgeSessionsAfterHours, default 48). If the platform's temp storage is reclaimed sooner, the worst case is a "start a new session" message on the next turn — no data is lost, since finished results are saved as normal Craft assets.

Privacy

Images and prompts are sent to the AI provider(s) you configure — the edit driver, plus the analysis driver when you've set a separate one — for processing. Make sure this is acceptable for your project's data-handling obligations before enabling the plugin. The editor shows a note naming the provider(s) at the point of use.

Extending

Additional providers can register edit drivers through the EVENT_REGISTER_EDIT_DRIVERS event:

Drivers implement spacecatninja\aiimageeditor\drivers\EditDriverInterface.

Lifecycle events

Four events let you observe, adjust, or veto edits and saves:

Event Fired on When Event class
EVENT_BEFORE_EDIT SessionsService Before each turn is sent to the driver EditEvent
EVENT_AFTER_EDIT SessionsService After a successful turn EditEvent
EVENT_BEFORE_SAVE FinalizeService Before the result is saved as an asset SaveEvent
EVENT_AFTER_SAVE FinalizeService After the result is saved SaveEvent

EditEvent carries the session, the request (mutable), the result (on the after event), and isValid. SaveEvent carries the session, the asset, a replace flag, and isValid. Set isValid = false in a "before" handler to cancel.

Permissions

The plugin registers two user permissions under an "AI Image Editor" group, assignable per user group:

These gate the editor's entry points and endpoints; the volume permissions (saveAssets, replaceFiles) still gate the actual save. Reference the handles from SessionsController::PERMISSION_EDIT / PERMISSION_GENERATE.

Support

Found a bug or have a feature request? Open an issue on the issue tracker. For anything else, email [email protected].

License

This is commercial software. See LICENSE.md. A license can be purchased through the Craft Plugin Store.


Brought to you by SPACECATNINJA


All versions of ai-image-editor with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
craftcms/cms Version ^5.0.0
guzzlehttp/guzzle Version ^7.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package spacecatninja/ai-image-editor contains the following files

Loading the files please wait ...