MVP Verson: 0.4.8 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
PropTypeValueDescriptionDefault Value
imageUrlString | 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-
watermarkConfigObjectObjectConfiguring watermark parameters{}
useInkify Tokens
TokenTypeValueDescriptionDefault Value
textString | String[]"text" | ["line1","line2"]Watermark content and supports multiple text lines-
fontSizeNumber20Font size of the watermark text30
colorString#fffText color of the watermark (supports CSS color values)rgba(255, 255, 255, 0.5)
rotateNumber30Rotation angle of the watermark in degrees30
spacingNumber100Horizontal spacing between watermark instances100
lineHeightNumber30Vertical line height between watermark rows30
opacityNumber0.5Transparency level (0 = fully transparent, 1 = fully opaque)0.5