smallpics/smallpics-php 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

smallpics/smallpics-php

最新稳定版本:1.0.1

Composer 安装命令:

composer require smallpics/smallpics-php

包简介

A PHP client library for generating URLs with Small Pics

README 文档

README

A PHP client library for generating URLs with Small Pics. This package provides a simple way to build URLs with Small Pics processing options.

Installation

composer require smallpics/smallpics-php

Usage

Creating Processing Options

use smallpics\smallpics\Options; // Create a new Options object $options = new Options(); // Set options with individual setters $options ->setWidth(300) ->setHeight(400); // Generate the query string parameters echo $options->toString(); // Output: "width=300&height=400" // Options object can also be used directly in a string context echo $options; // Output: "width=300&height=400"

Alternative Initialization

It is possible to initialize the Options object with an associative array. The keys of the array are the option names and the values are the option values.

The values can either be a single value, an array of values, or an associative array of values.

  • When a single value is used, it is passed as the first argument to the setter method.
  • When an array of values is used, they are destructured as passed as arguments in order to the setter method.
  • When an associative array is used, the key/value pairs are destructured and passed in as named arguments to the setter method.
// Create Options object with array of values $options = new Options([ 'width' => 300, 'height' => 400, 'fit' => 'fill', 'watermarkPosition' => 'center', 'border' => [ 'width' => 10, 'color' => '000000', 'borderMethod' => 'overlay', ], ]);

Building URLs

use smallpics\smallpics\Options; use smallpics\smallpics\UrlBuilder; // Create options object $options = new Options(); $options ->setQuality(80) ->setFormat('png'); // Create URL builder (without signing, with plain URLs) $builder = new UrlBuilder('https://images.my-origin.com', null, null, false); // Build URL $imageUrl = 'https://example.com/images/image.jpg'; $url = $builder->buildUrl($imageUrl, $options); echo $url; // Output: https://images.my-origin.com/images/image.jpg?q=80&fm=png

Signed URLs

// Create URL builder with signing keys $secret = '0123456789abcdef0123456789abcdef'; $builder = new UrlBuilder('https://images.my-origin.com', $secret); // Build signed URL $imageUrl = 'images/image.jpg'; $url = $builder->buildUrl($imageUrl, $options); echo $url; // Output will include a signature: https://images.my-origin.com/images/image.jpg?signature=[signature]

Development

Testing

This package uses Pest PHP for testing. To run the tests:

composer test

or

vendor/bin/pest

统计信息

  • 总下载量: 4.84k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固