choowx/rasterize-svg
最新稳定版本:v0.1.2
Composer 安装命令:
composer require choowx/rasterize-svg
包简介
A PHP library for converting SVG to JPEG, PNG, and WEBP
README 文档
README
Installation
You can install the package via composer:
composer require choowx/rasterize-svg
This package relies on the sharp js package being available on your system. In most cases you can accomplish this by issue this command in your project.
npm install sharp
Usage
use Choowx\RasterizeSvg\Svg; $svgString = '<svg width="100" height="100" viewBox="0 0 100 100"...'; $jpegBinaryString = Svg::make($svgString)->toJpeg(); $jpegBinaryString = Svg::make($svgString)->toJpg(); // Alias of toJpeg() $pngBinaryString = Svg::make($svgString)->toPng(); $webpBinaryString = Svg::make($svgString)->toWebp();
If you want to straight away save the rasterized image on disk:
use Choowx\RasterizeSvg\Svg; $svgString = '<svg width="100" height="100" viewBox="0 0 100 100"...'; Svg::make($svgString)->saveAsJpeg('path/to/rasterized.jpeg'); Svg::make($svgString)->saveAsJpg('path/to/rasterized.jpg'); // Alias of saveAsJpeg() Svg::make($svgString)->saveAsPng('path/to/rasterized.png'); Svg::make($svgString)->saveAsWebp('path/to/rasterized.webp');
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 47.94k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 22
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 未知