bertmaurau / php-watermarker
一个用于给图片添加水印的简单且基础的包。
dev-master
2019-01-08 10:30 UTC
Requires
- php: >=7.1
Requires (Dev)
- phpunit/phpunit: 6.*
This package is not auto-updated.
Last update: 2024-09-26 20:43:55 UTC
README
这是一个使用源图像和水印图像为图片添加水印的简单且基础的库。函数可以作为静态调用者或初始化函数使用(请参阅示例)。
使用方法
安装
通过 Composer
composer require bertmaurau/php-watermarker
示例
// example (examples/add-watermark.php) use BertMaurau\Watermarker; // the source/original image $sourceImage = __DIR__ . DIRECTORY_SEPARATOR . 'source.jpg'; // the image used as the watermark $watermarkImage = __DIR__ . DIRECTORY_SEPARATOR . 'watermark.png'; // available positions /* * Position:: TOP_LEFT | TOP_CENTER | TOP_RIGHT | CENTER_CENTER | BOTTOM_LEFT | BOTTOM_CENTER | BOTTOM_RIGHT */ // available imageTypes /* * ImageType:: JPEG | BMP | GIF | PNG */ // Static method /** * Function arguments * @param string required $sourceImage The image to put the watermark on * @param string required $watermarkImage The image that you want to use as a watermark * @param string optional $outputPath The path where the generated image should be placed (check your permissions) * @param string optional $outputFilename The filename you want to give the exported file * @param string optional $outputExtension The extension it should have * @param string optional $position The position to put the watermark at * @param int optional $outputQuality The exported quality (Used for .jpg or for compression with .png [1-100]) */ try { Watermarker\Watermark::AddImageAsWatermark($sourceImage, $watermarkImage, __DIR__, $filename = Watermarker\Position::CENTER_CENTER, Watermarker\ImageType::JPEG, Watermarker\Position::BOTTOM_CENTER, 100); } catch (\Exception $ex) { echo $ex -> getMessage(); } // Initialized mathod try { $marker = (new Watermarker\Watermark) -> setSourceImage($sourceImage) -> setWatermarkImage($watermarkImage) -> setOutputPath(__DIR__) // other setters -> watermark(); } catch (Exception $ex) { echo $ex -> getMessage(); }
问题
用于错误报告或代码讨论。
致谢
许可协议
该模块使用 MIT 许可协议。
