We built DEV3 AI Product Image Studio as a WooCommerce plugin in PHP with a React admin. The model does the creative part of each edit; everything that has to be exact (transparency, framing, size, file format, where the image goes) is done afterwards on the server with the PHP GD extension.
Key design decisions
- Transparency by chroma key, not by asking. For a transparent background the prompt asks for the product on pure
#00FF00. Image_Tools::chroma_key() then keys that colour out locally with a soft edge ramp and green despill, and the result is saved as a PNG with alpha.
- Framing is arithmetic. Pack shots go through
Image_Tools::square(): find the content box, scale the product's longest side to the chosen fill percentage (40–100%), centre it on a square canvas of the chosen colour. The same function is the AI-free Square canvas tool.
- Honest upscaling. The model restores detail and removes noise at the size it can produce (about 1 MP); the plugin then resamples to 2x, 4x or a target long edge, capped by a setting and a hard 4,096 px limit.
- Originals are never written to. Every result, AI or local, becomes a new attachment flagged
_dev3is_draft, hidden from the media library and listed in a review queue with a before/after slider. Approve replaces the image in the same slot (featured, gallery position or variation), adds it to the gallery, or keeps it in the library. Revert puts the original back.
- Stale approvals are refused. If the original is no longer in the product when someone approves a replacement, the API returns a 409 and offers Add to gallery or Keep in library instead of guessing.
- Useful without AI. Square canvas, resize with sharpening, flatten, format conversion, alt text templates, the image audit and the review queue all work with no API key.
Architecture
A product image library lists every featured, gallery and variation image with health flags from a local audit: border whiteness on a 64 px sample, squareness, resolution and missing alt text, cached per attachment by file time and size. The Studio runs one operation on one image; Batch runs an operation or a saved recipe over a selection, a category or a filtered catalogue on background jobs (Action Scheduler when WooCommerce provides it, WP-Cron otherwise) with progress, cancel and retry. Images are downscaled to 1,536 px before they are sent to the model. Alt text, titles and captions come from a vision call with a length-capped JSON schema and are never saved without a click. A [dev3is_compare] shortcode and a Before & After block show transformations on the storefront. The API client, settings, usage logs, jobs and the admin UI kit come from a shared core used across DEV3's plugins.