Under maintenanceMVP Verson: 0.9.7 beta
Lang Icon
Toggle Icon
useInkify hook can help you quickly realize the need to add watermarks on images.
How to use?
1.Installation
npm i tango-watermark
2.Import
import { useInkify } from "tango-watermark";
3.Use
Copy Logo
// react
import { useState } from "react";
import { useInkify } from "tango-watermark";
import { Space } from "tango-ui-cw";
import imageUrl from "@/asstes/yourimage.jpg";

const Demo = () => {
  const [finalUrl, setFinalUrl] = useState();

  const watermarkConfig = {
    text: "Tango UI",
    fontSize: 100,
    color: "white",
    rotate: -40,
    spacing: 250,
    lineHeight: 60,
    opacity: 0.7,
  };

  useInkify(imageUrl, watermarkConfig)
    .then((dataUrl) => {
      setFinalUrl(dataUrl);
    })
    .catch((error) => {
      console.error("error:", error);
    });

  return (
    <Space className="flex flex-col items-center gap-5 p-5 font-sans">
      <Space className="text-xl font-bold mb-3">Demo</Space>
      <Space className="flex gap-10 justify-center">
        <Space className="text-center">
          <h3 className="my-2 text-gray-600">Before</h3>
          <img
            src={imageUrl}
            alt="original"
            className="w-[500px] border border-gray-200 rounded-lg shadow-md"
          />
        </Space>
        <Space className="text-center">
          <h3 className="my-2 text-gray-600">After</h3>
          <img
            src={finalUrl}
            alt="with-watermark"
            className="w-[500px] border border-gray-200 rounded-lg shadow-md"
          />
        </Space>
      </Space>
    </Space>
  );
};

export default Demo;
Demo

Before

original

After

loading...
Lines
Text
Size
Color
Rotate
Space
Opacity
useInkify Props
Prop
Type
Value
Description
Default Value
imageUrl
String | HTMLImageElement | Blob
"http://example.com/image.jpg" | document.getElementById('myImage') | fileInput.files[0]
image source,support image URL、HTML image element or binary Blob data that already exists on the page
-
watermarkConfig
Object
Object
Configuring watermark parameters
{}
useInkify Tokens
Token
Type
Value
Description
Default Value
text
String | String[]
"text" | ["line1","line2"]
Watermark content and supports multiple text lines
-
fontSize
Number
20
Font size of the watermark text
30
color
String
#fff
Text color of the watermark (supports CSS color values)
rgba(255, 255, 255, 0.5)
rotate
Number
30
Rotation angle of the watermark in degrees
30
spacing
Number
100
Horizontal spacing between watermark instances
100
lineHeight
Number
30
Vertical line height between watermark rows
30
opacity
Number
0.5
Transparency level (0 = fully transparent, 1 = fully opaque)
0.5