Generates image placeholders on the fly with custom dimensions and colors.
- Generate placeholders from image URLs.
- Customize dimensions and background/text color.
- Utilizes
sharp
,jimp
, andcanvas
for image processing.
npm install picture-placeholder-generator
const generatePlaceholder = require('picture-placeholder-generator');
async function createPlaceholder() {
const { original, placeholder } = await generatePlaceholder('https://your-image-url.com/image.jpg', 200, 200, '#cccccc', '#969696');
// Use `original` and `placeholder` buffers as needed
}
createPlaceholder();
generatePlaceholder(url, width, height, color, textColor)
url
: Image URL to generate the placeholder for.width
: Width of the placeholder image (default 150).height
: Height of the placeholder image (default 150).color
: Background color of the placeholder (default\#cccccc
).textColor
: Color of the placeholder text (default\#969696
).
Contributions are welcome. Please open an issue or submit a pull request.
MIT