返回顶部
w

watermark-pro水印工具

文件水印工具。Use when user wants to add watermark to images, Word, PowerPoint, or PDF files. Supports text watermark, logo watermark, diagonal/center/tile layouts. 图片水印、文档水印、Word加水印、PPT加水印。

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.4
安全检测
已通过
186
下载量
免费
免费
0
收藏
概述
安装方式
版本历史

watermark-pro

Watermark Pro

文件水印工具,支持图片、Word、PPT、PDF添加水印。

功能特性

  • - 🖼️ 图片水印:支持JPG/PNG/WEBP格式
  • 📄 Word水印:支持.docx格式
  • 📊 PPT水印:支持.pptx格式
  • 📑 PDF水印:支持.pdf格式
  • ✍️ 文字水印:自定义文字、字体、颜色
  • 🖼️ Logo水印:支持透明PNG Logo
  • 📍 多种布局:对角线/居中/平铺

触发条件

  • - 加水印 / Add watermark
  • 图片加水印 / Word文档加水印
  • watermark-pro

第一步:图片水印

python
from PIL import Image, ImageDraw, ImageFont
import os

class ImageWatermark:
def addtextwatermark(self, imagepath, text, outputpath,
font_size=None, color=(128, 128, 128),
opacity=0.3, angle=-45, layout=diagonal, density=200):
img = Image.open(image_path).convert(RGBA)
width, height = img.size
watermark = Image.new(RGBA, img.size, (0, 0, 0, 0))
draw = ImageDraw.Draw(watermark)

if font_size is None:
font_size = max(width, height) // 30

try:
font = ImageFont.truetype(/System/Library/Fonts/PingFang.ttc, font_size)
except:
font = ImageFont.load_default()

alpha = int(255 * opacity)
fill_color = (*color, alpha)

if layout == diagonal:
for y in range(0, height, density):
for x in range(0, width, int(density * 1.4)):
draw.text((x, y), text, font=font, fill=fill_color)
elif layout == center:
bbox = draw.textbbox((0, 0), text, font=font)
tw = bbox[2] - bbox[0]
th = bbox[3] - bbox[1]
draw.text(((width-tw)//2, (height-th)//2), text, font=font, fill=fill_color)

watermark = watermark.rotate(angle, expand=False, resample=Image.BICUBIC)
result = Image.alpha_composite(img, watermark)

if output_path.lower().endswith(.jpg):
result = result.convert(RGB)
result.save(output_path)
return output_path



第二步:Word水印

python
from docx import Document
from docx.shared import Pt, RGBColor
from docx.enum.text import WDALIGNPARAGRAPH

class WordWatermark:
def addtextwatermark(self, docxpath, text, outputpath,
font_size=48, color=(200, 200, 200)):
doc = Document(docx_path)

for section in doc.sections:
header = section.header
header.islinkedto_previous = False

for para in header.paragraphs:
para.clear()

para = header.paragraphs[0] if header.paragraphs else header.add_paragraph()
para.alignment = WDALIGNPARAGRAPH.CENTER

run = para.add_run(text)
run.font.size = Pt(font_size)
run.font.color.rgb = RGBColor(*color)
run.font.name = 宋体

para.paragraphformat.spacebefore = Pt(250)

doc.save(output_path)
return output_path



第三步:PowerPoint水印

python
from pptx import Presentation
from pptx.util import Inches, Pt
from pptx.dml.color import RGBColor
from pptx.enum.text import PP_ALIGN

class PptWatermark:
def addtextwatermark(self, pptxpath, text, outputpath,
font_size=60, color=(200, 200, 200)):
prs = Presentation(pptx_path)

for slide in prs.slides:
txBox = slide.shapes.add_textbox(Inches(1.5), Inches(3), Inches(7), Inches(1.5))
tf = txBox.text_frame
p = tf.paragraphs[0]
p.text = text
p.font.size = Pt(font_size)
p.font.color.rgb = RGBColor(*color)
p.alignment = PP_ALIGN.CENTER

prs.save(output_path)
return output_path



第四步:PDF水印(图片叠加)

python
import fitz
from PIL import Image, ImageDraw, ImageFont
import os

class PdfWatermark:
def addtextwatermark(self, pdfpath, text, outputpath,
font_size=28, color=(128, 128, 128),
opacity=0.25, density=220):
doc = fitz.open(pdf_path)

for page in doc:
rect = page.rect
width, height = int(rect.width), int(rect.height)

wm_img = Image.new(RGBA, (width, height), (0, 0, 0, 0))
draw = ImageDraw.Draw(wm_img)

try:
font = ImageFont.truetype(/System/Library/Fonts/PingFang.ttc, font_size)
except:
font = ImageFont.load_default()

alpha = int(255 * opacity)
fill = (*color, alpha)

for y in range(0, height, density):
for x in range(0, width, int(density * 1.4)):
draw.text((x, y), text, font=font, fill=fill)

tempimg = os.path.join(os.path.dirname(outputpath), tempwm.png)
wmimg.save(tempimg)

page.insertimage(rect, filename=tempimg, overlay=True)

doc.save(output_path)
doc.close()

if os.path.exists(temp_img):
os.remove(temp_img)

return output_path



使用示例

用户:给图片加版权所有水印
助手:使用 ImageWatermark.addtextwatermark()

用户:Word文档加机密水印
助手:使用 WordWatermark.addtextwatermark()

用户:PDF加水印,密度高一点
助手:使用 PdfWatermark.addtextwatermark(density=150)



注意事项

  • - 纯本地处理,无隐私风险
  • 支持中英文水印
  • 跨平台兼容

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 watermark-pro-1776018914 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 watermark-pro-1776018914 技能

通过命令行安装

skillhub install watermark-pro-1776018914

下载

⬇ 下载 watermark-pro v1.0.4(免费)

文件大小: 3.42 KB | 发布时间: 2026-4-13 12:32

v1.0.4 最新 2026-4-13 12:32
恢复完整代码示例,精简文字描述,确保功能完整

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部