Quick Start
This guide walks you through creating a complete image workflow using FloImg.
Fastest Way: npx
Section titled “Fastest Way: npx”Transform images instantly from your terminal:
# Resize for social medianpx @teamflojo/floimg resize hero.png 1200x630 -o og-image.png
# Convert to WebPnpx @teamflojo/floimg convert image.png -o image.webp
# Add a caption or watermarknpx @teamflojo/floimg caption photo.jpg "© 2025 Acme" -o watermarked.jpg
# Generate with AI (requires OPENAI_API_KEY)npx @teamflojo/floimg generate openai "A mountain landscape at sunset" -o landscape.png
# Also: charts, diagrams, QR codesnpx @teamflojo/floimg qr "https://floimg.com" -o qr.pngSee the CLI docs for all available commands.
SDK: Use in Code
Section titled “SDK: Use in Code”For integration into your applications, use the FloImg SDK.
Prerequisites
Section titled “Prerequisites”Make sure you have installed floimg.
Step 1: Create a Client
Section titled “Step 1: Create a Client”Every floimg workflow starts with a client:
import createClient from '@teamflojo/floimg';
const floimg = createClient();Step 2: Register Generators
Section titled “Step 2: Register Generators”Generators create images. Register the ones you need:
import openai from '@teamflojo/floimg-openai';
floimg.registerGenerator(openai({ apiKey: process.env.OPENAI_API_KEY}));Step 3: Generate an Image
Section titled “Step 3: Generate an Image”Use the generate method with a generator name and parameters:
const image = await floimg.generate({ generator: 'openai', params: { prompt: 'A serene mountain landscape at golden hour', size: '1024x1024' }});Step 4: Transform the Image
Section titled “Step 4: Transform the Image”Apply transformations like resize, blur, or format conversion:
const resized = await floimg.transform(image, { op: 'resize', params: { width: 800, height: 600 }});
const final = await floimg.transform(resized, { op: 'modulate', params: { saturation: 1.2 }});Step 5: Save the Result
Section titled “Step 5: Save the Result”Save to local filesystem or cloud storage:
// Local fileawait floimg.save(final, './output/landscape.png');
// S3 bucket (requires AWS credentials)await floimg.save(final, 's3://my-bucket/images/landscape.png');Complete Example
Section titled “Complete Example”Here’s the full workflow:
import createClient from '@teamflojo/floimg';import openai from '@teamflojo/floimg-openai';
async function main() { // Initialize const floimg = createClient(); floimg.registerGenerator(openai({ apiKey: process.env.OPENAI_API_KEY }));
// Generate const image = await floimg.generate({ generator: 'openai', params: { prompt: 'A professional product photo of wireless headphones on a minimalist background', size: '1024x1024', quality: 'hd' } });
// Transform for social media const final = await floimg.transform(image, { op: 'resize', params: { width: 1200, height: 630 } });
// Save await floimg.save(final, './product-hero.png'); console.log('Image saved!');}
main();Next Steps
Section titled “Next Steps”- Core Concepts - Understand generators, transforms, and more
- SDK Reference - Full API documentation
- Plugins - Explore all available generators