rafiki23 / watermarkcredits
WatermarkCredits 是一个 Laravel 包,允许用户轻松地在图片上应用带有水印和作者信息的标记。
0.0.2
2023-12-06 22:47 UTC
Requires
- php: ^7.4 || ^8.0 || ^8.1
- ext-gd: *
- intervention/image: ^2.5
- laravel/framework: ^9.0|^10.0
README
WatermarkCredits 是一个 Laravel 包,用于轻松地在图片上应用水印和作者信息。
它提供了一个简单的接口来应用自定义水印,可调节透明度级别,并可选择添加补充文本。
这对于摄影师、内容创作者和希望保护其作品并确保其图片上正确归属作者身份的企业来说非常合适。
安装
使用 composer 安装包
composer require rafiki23/watermarkcredits
将服务提供者添加到您的 config/app.php
文件中
'providers' => [ // Other Service Providers Rafiki23\WatermarkCredits\WatermarkServiceProvider::class, ],
发布配置文件
php artisan vendor:publish --provider="Rafiki23\WatermarkCredits\WatermarkServiceProvider" --tag="config"
配置
发布配置文件后,它位于 config/watermark.php
。您可以修改它以设置默认配置。
return [ 'opacity' => 0.6, // 60% opacity 'rectangle_color' => [0, 0, 0, 0.6], // black with 50% opacity 'text_color' => '#ffffff', // white 'font_size' => 24, // default font size 'font_path' => resource_path('fonts/Arial.ttf'), // path to the font file, assuming Arial.ttf is in the "fonts" folder under "resources" 'font_ratio' => 0.1, // font size as a ratio of image height 'default_logo_path' => resource_path('img/yourlogo.png'), // Default logo path, if you have a standard logo you want to use ];
使用方法
以下是如何使用 WatermarkCredits 包的示例
use Rafiki23\WatermarkCredits\Watermark; $watermark = new Watermark(); // Apply watermark to an image $watermark->applyWatermark('path/to/image.jpg', 'Author name')->save('path/to/output/image.jpg');
您也可以指定自定义标志
$watermark->applyWatermark('path/to/image.jpg', 'Author name', 'path/to/your/custom/logo.png')->save('path/to/output/image.jpg');
许可证
WatermarkCredits 包是开源软件,许可协议为 MIT 许可协议。