承接 yarri/material-palette 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

yarri/material-palette

最新稳定版本:1.3.0

Composer 安装命令:

composer require yarri/material-palette

包简介

Prominent image colour extraction for PHP

README 文档

README

Logo

Palette is a port of the Android library of the same name, for extracting a colour palette from an image. The results can then be used for tinting the interface to match the image.

Installation

$ composer require 'marijnvdwerf/material-palette:~1.0'

Usage

Palette makes use of the Intervention image library to load images, and supports both the Imagick and GD drivers. The performance of the Imagick driver is slightly better, but the difference is fairly small.

$manager = new ImageManager(array('driver' => 'imagick'));
$image = $manager->make('path/to/image.png');

$palette = Palette::generate($image);
echo $palette->getVibrantSwatch()->getColor();

Contrast

You can get the contrast of a colour on a non-translucent background by calling AbstractColor::calculateContrast($background, $foreground). Information on the recommended contrast ratio can be found at the W3C recommendation.

$white = new RGBColor(1, 1, 1);
$black = new RGBColor(0, 0, 0);
$background = $palette->getVibrantSwatch()->getColor();

echo '<div style="background: ' . $background . '">';
if(AbstractColor::calculateContrast($background, $white) >= 3) {
    echo '<h1 style="color: white;">Palette</h1>';
} else {
    echo '<h1 style="color: black;">Palette</h1>';
}
echo '</div>';

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2025-09-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固