Getting Started
Everything you need to start using Imigi in your project.
Requirements
Before installing Imigi, make sure your environment meets the following requirements:
| Requirement | Minimum Version |
|---|---|
| Chrome | 80+ |
| Firefox | 78+ |
| Safari | 14+ |
| Edge | 80+ |
| Node.js (for npm installation) | 16+ |
async/await and ES modules. Internet Explorer is not supported.
Installation
Choose your preferred package manager or load Imigi directly from a CDN.
npm install imigi
yarn add imigi
pnpm add imigi
Include the UMD bundle directly in your HTML. No build step required.
<script src="https://unpkg.com/imigi/dist-umd/imigi.umd.js"></script>
Imigi object is available globally on window.Imigi.
Quick Start (ES Module)
If you are using a bundler such as Vite, Webpack, or Rollup, import Imigi as an ES module:
import { Imigi } from 'imigi';
const editor = await Imigi.init({
selector: '#editor-container',
image: 'path/to/image.jpg',
});
That's it. Imigi will render the editor inside the element matching #editor-container and load the specified image.
Imigi.init() returns a Promise that resolves to the editor instance. Always await it (or use .then()) before interacting with the editor API.
Quick Start (UMD / Script Tag)
If you prefer a zero-build setup, include the UMD bundle via a <script> tag:
<!-- Container for the editor -->
<div id="editor-container" style="width:100%;height:600px;"></div>
<!-- Load Imigi -->
<script src="imigi.umd.js"></script>
<script>
Imigi.init({
selector: '#editor-container',
image: 'photo.jpg',
});
</script>
HTML Setup
Below is a complete HTML boilerplate you can copy and paste to get started immediately:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Imigi Editor</title>
<style>
body { margin: 0; font-family: sans-serif; }
#editor-container { width: 100vw; height: 100vh; }
</style>
</head>
<body>
<div id="editor-container"></div>
<script src="https://unpkg.com/imigi/dist-umd/imigi.umd.js"></script>
<script>
Imigi.init({
selector: '#editor-container',
image: 'https://picsum.photos/800/600',
});
</script>
</body>
</html>
Loading an Image
Imigi supports multiple ways to load an image into the editor. Choose the approach that fits your use case.
From a URL
Pass the image URL directly in the configuration:
const editor = await Imigi.init({
selector: '#editor',
image: 'https://example.com/photo.jpg',
});
crossOrigin: 'anonymous' in your configuration and ensure the server sends the appropriate Access-Control-Allow-Origin headers. See the Security section for details.
From a File Input
Let users pick an image from their device using a standard file input:
const fileInput = document.getElementById('file-input');
fileInput.addEventListener('change', async (e) => {
const file = e.target.files[0];
if (!file) return;
const url = URL.createObjectURL(file);
const editor = await Imigi.init({
selector: '#editor',
image: url,
});
});
From a Data URL / Base64
You can also load images from a base64-encoded data URL string:
const base64Image = 'data:image/png;base64,iVBORw0KGgo...';
const editor = await Imigi.init({
selector: '#editor',
image: base64Image,
});
Creating a Blank Canvas
To start with an empty canvas instead of an existing image, use the blankCanvasSize option:
const editor = await Imigi.init({
selector: '#editor',
blankCanvasSize: { width: 800, height: 600 },
});
This creates an 800×600 pixel white canvas. You can then use the drawing tools, add text, shapes, or stickers to build a design from scratch.
blankCanvasSize is set, the image option is ignored. You can change the canvas background color later using the Fill Tool.
Handling Save
Use the onSave callback to handle the edited image when the user clicks Save:
const editor = await Imigi.init({
selector: '#editor',
image: 'photo.jpg',
onSave: (data, filename, format) => {
// data is a base64 string or JSON (depending on format)
console.log('Saved:', filename, format);
// Example: download the file
const link = document.createElement('a');
link.href = data;
link.download = filename;
link.click();
},
});
The onSave callback receives three arguments:
'json'.'photo.png').'png', 'jpeg', 'webp', 'svg', or 'json'.Example: Upload to a Server
onSave: async (data, filename, format) => {
const blob = await fetch(data).then(r => r.blob());
const formData = new FormData();
formData.append('image', blob, filename);
await fetch('/api/upload', {
method: 'POST',
body: formData,
});
alert('Image uploaded successfully!');
}
Inline vs Overlay Mode
Imigi supports two display modes that control how the editor is rendered on your page.
Inline Mode (default)
In inline mode, the editor renders directly inside the target container as part of the page flow. This is the default behavior.
const editor = await Imigi.init({
selector: '#editor',
image: 'photo.jpg',
ui: {
mode: 'inline', // This is the default
},
});
Use inline mode when the editor is a permanent part of the page layout, such as in a dedicated editing view or an admin panel.
Overlay Mode
In overlay mode, the editor appears as a fullscreen modal on top of your page. The user can open it, edit, and then close it.
const editor = await Imigi.init({
selector: '#editor',
image: 'photo.jpg',
ui: {
mode: 'overlay',
},
onClose: () => {
console.log('Editor closed');
},
});
// Open the editor later
editor.open();
// Close it programmatically
editor.close();
Overlay mode is ideal when you want users to edit images on demand without leaving the current page, for example when clicking an "Edit" button on a thumbnail.
| Feature | Inline | Overlay |
|---|---|---|
| Renders inside container | Yes | No (fullscreen modal) |
| Visible on load | Yes | No (call editor.open()) |
| Close button | No | Yes |
| Best for | Dedicated editing pages | On-demand editing flows |
onClose callback fires when the user dismisses the editor. Use it to clean up resources or update your UI.
Next Steps
Now that you have Imigi up and running, explore these guides to unlock its full potential:
Configuration
Learn about all configuration options including UI settings, tool presets, export formats, and more.
API Reference
Full reference for the Imigi instance methods, properties, and static helpers.
Tools Guide
Deep dive into each editing tool: filters, crop, draw, text, shapes, stickers, and more.
Integrations
Framework-specific guides for React, Vue, Angular, Next.js, and Nuxt.