
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
text-behind-image
Advanced tools
Text-Behind-Image: A framework-agnostic npm package for applying the text-behind-image effect in web apps, compatible with React, Vue, Svelte and other modern frameworks. Inspired by the work of Rexan Wong.
A framework-agnostic package to display the text-behind-image effect in any web application or Node.js script. Inspired by the work of Rexan Wong and developed to be easily integrated directly into your projects.
npm install text-behind-image
This package provides a single core function, TextBehindImage, which takes an image (URL, File, or Blob), advanced text settings (single or multiple layers), and a result image format/output type to apply the text-behind-image effect.
Framework-agnostic: Works in any environment that supports the HTML Canvas API (browsers, Electron, Node.js with canvas).
import { TextBehindImage } from "text-behind-image";
const result = await TextBehindImage({
image: fileOrUrl, // string | File | Blob
textSettings: [
{
font: "Arial",
fontSize: 48,
color: "white",
content: "Sample Text",
position: { x: 100, y: 100 },
alignment: "center",
rotation: 0,
shadowColor: "#000",
shadowBlur: 10,
shadowOffsetX: 0,
shadowOffsetY: 0,
strokeColor: "#fff",
strokeWidth: 2,
opacity: 0.9,
letterSpacing: 2,
lineHeight: 1.5,
},
// ...more layers
],
format: "png",
outputType: "dataUrl", // or 'blob' | 'file'
bgRemovalOptions: { /* options for background removal */ },
});
import React, { useState } from "react";
import { TextBehindImage } from "text-behind-image";
const App = () => {
const [imageUrl, setImageUrl] = useState("");
const generateImage = async () => {
const result = await TextBehindImage({
image: "https://example.com/image.png",
textSettings: {
font: "Arial",
fontSize: 48,
color: "white",
content: "Sample Text",
position: { x: 100, y: 100 },
},
format: "png",
});
setImageUrl(result);
};
return (
<div>
<button onClick={generateImage}>Generate Image</button>
{imageUrl && <img src={imageUrl} alt="Generated" />}
</div>
);
};
<template>
<div>
<button @click="processImage">Generate Image</button>
<img v-if="imageUrl" :src="imageUrl" alt="Generated" />
</div>
</template>
<script setup>
import { ref } from 'vue';
import { TextBehindImage } from 'text-behind-image';
const imageUrl = ref('');
async function processImage() {
const result = await TextBehindImage({
image: 'https://example.com/image.png',
textSettings: {
font: 'Arial',
fontSize: 48,
color: 'white',
content: 'Sample Text',
position: { x: 100, y: 100 },
},
format: 'png',
});
imageUrl.value = result;
}
</script>
<script>
import { TextBehindImage } from 'text-behind-image';
let imageUrl = '';
async function generateImage() {
const result = await TextBehindImage({
image: 'https://example.com/image.png',
textSettings: {
font: 'Arial',
fontSize: 48,
color: 'white',
content: 'Sample Text',
position: { x: 100, y: 100 },
},
format: 'png',
});
imageUrl = result;
}
</script>
<button on:click={generateImage}>Generate Image</button>
{#if imageUrl}
<img src={imageUrl} alt="Generated" />
{/if}
TextBehindImageProcesses an image by applying a text-behind-image effect.
image (string | File | Blob): The image to process (URL, File, or Blob).textSettings (object | object[]): Settings for one or more text layers. Each object supports:
font (string): Font familyfontSize (number): Font sizecolor (string): Text colorcontent (string): Text contentposition (object): { x: number, y: number }alignment (CanvasTextAlign): Text alignmentrotation (number): Rotation in degreesshadowColor, shadowBlur, shadowOffsetX, shadowOffsetYstrokeColor, strokeWidthopacity (number): 0-1letterSpacing (number)lineHeight (number)format (string): Output format ('png', 'jpg', 'webp')outputType (string): 'dataUrl' (default), 'blob', or 'file'bgRemovalOptions (object): Options for background removal (see @imgly/background-removal)Promise<string | Blob | File>: The final image as a Data URL, Blob, or File.canvas package. See system dependencies below.canvas package.canvas: Used for rendering images and text.@imgly/background-removal: For background removal functionality.sudo apt-get install build-essential libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev
brew install pkg-config cairo pango libpng jpeg giflib librsvg
If you want to contribute to this project, feel free to open an issue or fork this repository & open a pull request. Please:
We appreciate all contributions that help make this package better!
Again, a big thanks to Rexan Wong for his incredible original work on the text-behind-image website, which inspired this package.
FAQs
Text-Behind-Image: A framework-agnostic npm package for applying the text-behind-image effect in web apps, compatible with React, Vue, Svelte and other modern frameworks. Inspired by the work of Rexan Wong.
The npm package text-behind-image receives a total of 0 weekly downloads. As such, text-behind-image popularity was classified as not popular.
We found that text-behind-image demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.