Generate high quality AI images on your computer in 10 minutes (Ghibli)
Log Entry 7: 2025-05-03 22:15 hrs KST
Update
I built a quick tool so my wife could Ghibli-style her photos. It runs locally using the OpenAI API. Took 10 minutes. It’s also on github.
Observation
Recently I was on a date with my wife. In keeping with internet trends, we decided to Ghibli-fy it. I just took photos throughout the day, a pretty normal thing to do. But this time, I uploaded each one to the ChatGPT iOS app and prompted it to return the image in Studio Ghibli style.
It worked surprisingly well. By the end of the date, we had 11 images that retold our day as a soft, painterly Ghibli memory.
I sent them to my wife. She was over the moon. She wanted to make her own.
But here’s the catch: even though she has ChatGPT Plus ($20/month), she doesn’t have access to the upgraded image generator. I was randomly selected from the beta rollout. Turns out, not all Plus accounts get the fancy image model, and are left with the boring Dalle 3 image model.
There’s a way around that.
You can use the OpenAI API to generate and edit images on your own. So I wrote a script, installed it on her laptop, and now she’s editing everything from travel photos to baby pictures with it.
Here’s how to get it running in under 10 minutes.
Experiment
A DIY Ghibli image editor using Node.js + OpenAI API.
Step 1: Get your API key
First, create a new project folder and set up your environment:
mkdir image-generator cd image-generator
Then, inside that folder, create a file called .env
and add your OpenAI API key:
OPENAI_API_KEY=your_api_key_here
Tip: You can find your API key by logging into platform.openai.com and generating a new one if needed.
Step 2: Install dependencies
Make sure you have Node installed.
Then, in your folder:
npm install openai dotenv
Step 3: Create your script
Save this file as make.js
:
import "dotenv/config";
import fs from "fs";
import path from "path";
import OpenAI from "openai";
import { mkdir } from "fs/promises";
const openai = new OpenAI({
apiKey: process.env.OPENAI_API_KEY,
});
async function editImage(prompt, inputImagePath, outputPath = null) {
if (!fs.existsSync(inputImagePath)) {
throw new Error(`Input image not found: ${inputImagePath}`);
}
if (!outputPath) {
const timestamp = new Date().toISOString().replace(/[:\.]/g, "-");
outputPath = path.join("images", `edited_${timestamp}.png`);
}
try {
await mkdir(path.dirname(outputPath), { recursive: true });
const ext = path.extname(inputImagePath).toLowerCase();
const mimeTypes = {
".jpg": "image/jpeg",
".jpeg": "image/jpeg",
".png": "image/png",
".webp": "image/webp",
};
const mimeType = mimeTypes[ext] || "image/png";
const imageStream = fs.createReadStream(inputImagePath);
const result = await openai.images.edit({
model: "gpt-image-1",
image: await OpenAI.toFile(imageStream, path.basename(inputImagePath), {
type: mimeType,
}),
prompt,
quality: "medium",
});
const image_base64 = result.data[0].b64_json;
const image_bytes = Buffer.from(image_base64, "base64");
fs.writeFileSync(outputPath, image_bytes);
console.log(`Edited image saved to ${outputPath}`);
return outputPath;
} catch (error) {
console.error(`Error editing image: ${error.message}`);
throw error;
}
}
async function main() {
const args = process.argv.slice(2);
if (args.length < 2) {
console.log(`
Usage: node imgEdit.js <prompt> <inputImagePath>
Example:
node make.js "Turn this into a Ghibli style" image.jpg
`);
return;
}
const prompt = args[0];
const inputImagePath = args[1];
try {
console.log(`Prompt: "${prompt}"`);
console.log(`Input image: ${inputImagePath}`);
await editImage(prompt, inputImagePath);
} catch (error) {
console.error(`Failed to edit image: ${error.message}`);
}
}
if (import.meta.url === `file://${process.argv[1]}`) {
main().catch((err) => console.error("Error in main execution:", err));
}
export { editImage };
Step 4: Run the script
In your terminal:
node make.js "make this image in the style of Ghibli" path/to/your/image.jpg
You can drag and drop the image into the terminal to auto-fill the path.
Capsule Note
Get around AI release limitations with local API calls.