A specialized CLI tool and SVGO plugin to optimize and validate SVGs for BIMI (Brand Indicators for Message Identification) compliance.
Install the package globally or as a development dependency:
# Install globally
npm install -g svgo-bimi
# Or install as a dev dependency
npm install --save-dev svgo-bimiYou can run the tool without installing it locally by using npx:
npx svgo-bimi -f path/to/logo.svg -o ./distIf installed globally or in your project:
svgo-bimi -f <path-to-svg> -o <output-directory>// svgo.config.js
import { svgoBimiPlugin } from 'svgo-bimi';
export default {
// ...
plugins: [
// ...
svgoBimiPlugin
// ...
]
// ...
};SVGO's default preset may remove SVG Tiny 1.2 metadata during optimization. The CLI restores exactly one version="1.2" and baseProfile="tiny-ps" attribute in the output; other SVGO plugins may still alter metadata when using the plugin directly. Arc path commands (A/a), which SVG Tiny 1.2 does not support, are approximated with cubic Bézier curves, and the CLI disables SVGO's arc-recreation optimization so those commands are not reintroduced. Root-level SVG presentation attributes such as fill and stroke are retained so child elements keep their inherited appearance.
| Flag | Description | Required |
|---|---|---|
"-f, --file" |
Path to the source SVG file | Yes |
"-o, --output" |
Directory to save the optimized file (default: .) | No |
Adobe Illustrator is the most common tool for creating BIMI logos, but its default export settings often break compliance.
- "My logo turned into a black blob"
Cause: Illustrator often uses CSS Classes or
<style>blocks. BIMI requires Inline Attributes. Fix: When exporting, set CSS Properties to Presentation Attributes instead of Style Elements. - "Embedded bitmaps detected" Cause: You might have a raster image (PNG/JPG) placed inside your Illustrator file. Fix: You must use Object > Image Trace or manually redraw the shape with the Pen tool to make it a true vector.
- "Font tags detected" Cause: You left the brand name as editable text. Fix: Select all text and go to Type > Create Outlines (Shift + Ctrl/Cmd + O). BIMI does not support font files.
- Recommended Export Settings When using File > Save As > SVG: SVG Profile: SVG Tiny 1.2 Type: Convert to outline CSS Properties: Presentation Attributes Decimal Places: 2 (helps keep file size under 32KB)
- Version: Must be 1.2.
- Base Profile: Must be tiny-ps.
- No Bitmaps: No .png, .jpg, or Base64 encoded images.
- No Scripts: Interactive elements are strictly forbidden.
- Aspect Ratio: Must be 1:1 (Square).
- Size: Files must be 32KB or smaller.
This project uses the native Node.js test runner.
npm startnpm testThe test suite includes SVG visual regression checks. It rasterizes fixture inputs and CLI outputs with Resvg at 256 pixels wide, then fails if more than 1% of pixels differ.
MIT