mvccore / ext-tool-image
MvcCore - 扩展 - 工具 - 图片 - 支持许多流行网络图片操作的对象化图片处理工具。
v5.0.3
2022-04-21 09:55 UTC
Requires
- php: >=5.4.0
- mvccore/mvccore: ^5.0
README
安装
composer require mvccore/ext-tool-image
特性
扩展帮助处理许多流行的网络图片操作
Image Image::AddOverlay($overlayImgFullPath, $x, $y, $alpha, $composite); // Adding overlay image is not implemented for Gd adapter Image Image::ApplyMask($maskImgFullPath); Image Image::Contain($width, $height); Image Image::Cover($width, $height, $orientation); Image Image::CreateEmptyImageResource($width, $height, $hexBgColor = 'transparent'); Image Image::Crop($x, $y, $width, $height); Image Image::CropPercent($xPercentage, $yPercentage, $widthPercentage, $heightPercentage); Image Image::Frame($width, $height); int Image::GetHeight(); int Image::GetWidth(); Image Image::Grayscale(); array Image::HexColor2RgbArrayColor($hexColor); bool Image::IsVectorGraphic(); Image Image::Load($imgFullPath); Image Image::Resize($width, $height); Image Image::ResizeByHeight($height); Image Image::ResizeByPixelsCount($count); Image Image::ResizeByWidth($width); Image Image::Rotate($angle); Image Image::RoundCorners($x, $y); Image Image::Sepia($threshold = 80); Image Image::SetBackgroundColor($hexColor); Image Image::SetBackgroundImage($bgImgFullPath); Image Image::Save($imgFullPath, $format, $quality); Image Image::UnsharpMask($amount, $radius, $threshold);
使用
<?php include_once('vendor/autoload.php'); use \MvcCore\Ext\Tools; // resize `source.jpg` to `thumb.jpg`: $image = Tools\Image::CreateInstance() ->Load(__DIR__ . "/source.jpg") ->ResizeByHeight(150) ->UnsharpMask(300, 0.7, 50) ->Save( __DIR__ . "/thumb.jpg", Tools\Images\IFormat::JPG, 100 ); // display original and resized image: echo '<html><body>', '<img src="source.jpg" />', '<br />', '<img src="thumb.jpg" />', '</body></html>';