{"_id":"@dloizides/og-image-generator","name":"@dloizides/og-image-generator","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@dloizides/og-image-generator","version":"1.0.0","description":"Provider-agnostic build-time image generation (rasterize SVG -> PNG for OG/social cards and icons). The image seam of the generation abstraction.","keywords":["og-image","social-card","svg","rasterize","sharp","build-time","generation"],"author":{"name":"dloizides"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/openmindednewby/og-image-generator.git"},"homepage":"https://github.com/openmindednewby/og-image-generator#readme","bugs":{"url":"https://github.com/openmindednewby/og-image-generator/issues"},"main":"./dist/index.js","module":"./dist/index.mjs","types":"./dist/index.d.ts","exports":{".":{"require":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"import":{"types":"./dist/index.d.mts","default":"./dist/index.mjs"}}},"sideEffects":false,"engines":{"node":">=18.0.0"},"scripts":{"build":"rimraf dist && tsup","build:watch":"tsup --watch","test":"jest","test:watch":"jest --watch","test:coverage":"jest --coverage","lint":"eslint src --ext .ts","lint:fix":"eslint src --ext .ts --fix","typecheck":"tsc --noEmit","clean":"rimraf dist","security:audit":"npm audit --audit-level=high","prepublishOnly":"npm run clean && npm run build && npm run test"},"devDependencies":{"@types/jest":"^29.5.0","@types/node":"^20.19.32","@typescript-eslint/eslint-plugin":"^7.0.0","@typescript-eslint/parser":"^7.0.0","eslint":"^8.57.0","eslint-plugin-sonarjs":"^3.0.6","jest":"^29.7.0","rimraf":"^5.0.0","ts-jest":"^29.1.0","tsup":"^8.0.0","typescript":"^5.4.0"},"_id":"@dloizides/og-image-generator@1.0.0","_nodeVersion":"22.18.0","_npmVersion":"10.9.3","dist":{"integrity":"sha512-cIXzuklfrOvPcAEK6kilpmJ6dd3AsXCXh4bKxhJ3rsN/xXCgjXMvz9gucls47mAgUVqNEvA002jXp3PFeM4mWA==","shasum":"8b7c313c9e6b51d9e1aeb6d4cecb8003f81e599f","tarball":"https://registry.npmjs.org/@dloizides/og-image-generator/-/og-image-generator-1.0.0.tgz","fileCount":10,"unpackedSize":31341,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIDjWob8ZJ+8/wAM4ZrOupdIhrLDMdle0kcfnHvVN59wZAiB0pFHwv1k6t+Gx2yed9l1KJZ79tHHukX64r5A/k2Wa3A=="}]},"_npmUser":{"name":"dloizides","email":"loizidesdemetris@gmail.com"},"directories":{},"maintainers":[{"name":"dloizides","email":"loizidesdemetris@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/og-image-generator_1.0.0_1781688026700_0.6008793165826691"},"_hasShrinkwrap":false}},"time":{"created":"2026-06-17T09:20:26.505Z","1.0.0":"2026-06-17T09:20:26.830Z","modified":"2026-06-17T09:20:27.025Z"},"maintainers":[{"name":"dloizides","email":"loizidesdemetris@gmail.com"}],"description":"Provider-agnostic build-time image generation (rasterize SVG -> PNG for OG/social cards and icons). The image seam of the generation abstraction.","homepage":"https://github.com/openmindednewby/og-image-generator#readme","keywords":["og-image","social-card","svg","rasterize","sharp","build-time","generation"],"repository":{"type":"git","url":"git+https://github.com/openmindednewby/og-image-generator.git"},"author":{"name":"dloizides"},"bugs":{"url":"https://github.com/openmindednewby/og-image-generator/issues"},"license":"MIT","readme":"# @dloizides/og-image-generator\n\nProvider-agnostic **build-time image generation** — rasterise brand SVGs into PNG\nsocial cards (OG) and icons. This is the **image seam** of the cross-product\ngeneration abstraction (Capability Wave C3): consumers depend on the\n`ImageRasterizer` interface, never on a specific backend, so the rendering engine\n(today sharp, tomorrow a self-host/AI provider) is swappable without code change.\n\n## Why\n\nEvery site that ships an Open Graph card and an `apple-touch-icon` needs the same\nbuild step: take an SVG design source and emit a sized PNG. Instead of copy-pasting\na `sharp` script into each repo, depend on this package and pass the jobs in.\n\n## Install\n\n```bash\nnpm i -D @dloizides/og-image-generator sharp\n```\n\n`sharp` is **injected**, not a dependency of this package — you control its version\nand the package itself has zero runtime deps.\n\n## Use (build script)\n\n```js\nimport sharp from 'sharp';\nimport { resolve, dirname } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport {\n  SharpRasterizer,\n  generateOgImages,\n  nodeFileSystem,\n} from '@dloizides/og-image-generator';\n\nconst root = resolve(dirname(fileURLToPath(import.meta.url)), '..');\nconst p = (rel) => resolve(root, rel);\n\nawait generateOgImages(\n  [\n    { src: p('public/og-card.svg'), dst: p('public/og-card.png'), width: 1200, height: 630, fit: 'cover' },\n    { src: p('public/favicon.svg'), dst: p('public/apple-touch-icon.png'), width: 180, height: 180, fit: 'contain' },\n  ],\n  { rasterizer: new SharpRasterizer(sharp), fs: nodeFileSystem, logger: console },\n);\n```\n\nMissing sources are skipped with a warning (`written: false`), so a site without a\nfavicon SVG still builds.\n\n## API\n\n- **`ImageRasterizer`** — the seam: `rasterize(source: Buffer, opts): Promise<Buffer>`.\n- **`SharpRasterizer`** — build-time provider; `new SharpRasterizer(sharp)`.\n- **`generateOgImages(jobs, { rasterizer, fs, logger? })`** — orchestrates\n  read → rasterize → write per job (sequential; missing sources skipped).\n- **`nodeFileSystem`** — default `node:fs` filesystem port.\n- **Defaults** — `fit: 'cover'`, `density: 144`, `quality: 90`.\n\n## Adding a provider\n\nImplement `ImageRasterizer` (e.g. a self-host ComfyUI or an AI image API) and pass\nit to `generateOgImages` — no consumer change. The build-time sharp path stays the\ndefault for deterministic, dependency-light asset rendering.\n","readmeFilename":"README.md","_rev":"1-9e30d8109f74e9ae9979c34bd320fa9e"}