An npm library for WordPress theme creators: Easily convert image-based color palettes into theme.json
structures using this Node.js library powered by AI through the OpenRouter API and Google: Gemini Flash 2.0 Experimental.
To install wp-styler-ai
, run the following command:
npm install wp-styler-ai
Here's a quick example of how to use wp-styler-ai
:
import { ocr } from "wp-styler-ai";
async function main() {
const json = await ocr({
filePath: "./test/color-palette.png", // Path to your image
apiKey: process.env.OPENROUTER_API_KEY, // OpenRouter API key
});
console.log(json);
}
main();
This script processes an image and outputs a WordPress theme.json
color palette.
wp-styler-ai
uses Google's Gemini Flash 2.0 Experimental model via the OpenRouter API to perform Optical Character Recognition (OCR) on an image. The extracted color data is then formatted into a WordPress theme.json
color palette.
The default model used is google/gemini-2.0-flash-exp:free
.
- [x] Support for local image OCR
- [x] Generate WordPress
theme.json
color palettes - [ ] Add support for typography
This project was inspired by Llama OCR.