gevo/sqip_img_converter

使用sqip将图像转换为占位符

v1.0.0 2024-02-24 10:41 UTC

This package is auto-updated.

Last update: 2024-09-24 11:57:37 UTC


README

本项目提供了一个PHP类,用于使用Sqip将图像转换为SVG占位符。

安装

使用composer安装项目

composer require gevo/img-converter-sqip

Packagist链接

请确保在您的机器上全局安装了sqip,按照官方指南进行安装

用法

use Gevo\ImgConverterSqip\Converter;

$converter = new Converter($inputPath, $outputPath);
$converter->convert();

在此示例中,$inputPath是输入图像的路径,而$outputPath是SVG占位符应保存的路径。

异常处理

如果在转换过程中出现问题,convert方法可能会抛出ImgConverterSqipException异常。您应该在代码中捕获此异常并适当处理。

use Gevo\ImgConverterSqip\Converter;
use Gevo\ImgConverterSqip\ImgConverterSqipException;

try {
    $converter = new Converter($inputPath, $outputPath);
    $converter->convert();
} catch (ImgConverterSqipException $e) {
    // Handle exception
}

许可证

本项目采用MIT许可证。