kaia/watermarking 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

kaia/watermarking

最新稳定版本:v1.0.3

Composer 安装命令:

composer require kaia/watermarking

包简介

PHP Packages for adding watermark on image

README 文档

README

PHP Package where you can insert your own watermark on image. This package using PHP-GD for generating the watermark, so make sure you have PHP-GD installed before you use this package. For now this package only support on 4 positions, and will get update on future.

Requirement

  • php >= 8.0
  • php-gd

Installation

To install this package, run

  composer require kaia/watermarking

Now you can use it into your PHP project

  use Kaia\Watermarking\Watermark;

  /** Example create watermark using text
  Watermark::createFromText($sourcePath, $destinationPath, $watermarkText, $options[]);

  /** Example create watermark using image
  Watermark::createFromImage($sourcePath, $destinationPath, $watermarkPath, $options[]);

Available options

For "createFromText" method.

Key Type Value Default Value Note
position string top-left, top-right, bottom-left, bottom-right top-left optional
size integer any number 12 optional
color string hex color code (example #ffffff) #ffffff optional
font string path to your .ttf file arial.ttf optional

For "createFromImage" method.

Key Type Value Default Value Note
position string top-left, top-right, bottom-left, bottom-right top-left optional
opacity integer between 0.1 - 1.0 0.5 optional
scale integer between 0.1 - 1.0 0.2 optional

Example case :

I want create watermark with text "I am Kaia" on existing image :

  • Source Image Path = storage/images/image.jpeg
  • Destination Image Path = storage/images/watermarked/watermarked.jpeg
  • Watermark Position = Top Left
  • Watermark Font Size = 16
  • Font Path = storage/fonts/arial.ttf
  use Kaia\Watermarking\Watermark;

  Watermark::createFromText(
    'storage/images/image.jpeg', 
    'storage/images/watermarked/watermarked.jpeg', 
    'I am Kaia', 
    [
      'position' => 'top-left',
      'size' => '16',
      'font' => 'storage/fonts/arial.ttf'
    ]
  );

And the output will be like : Image

Support me

https://ko-fi.com/kaia3

统计信息

  • 总下载量: 2
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-02-20