承接 fjw/color-compare 相关项目开发

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

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

fjw/color-compare

Composer 安装命令:

composer require fjw/color-compare

包简介

A library for converting colors (Hex, RGB, HSL, CIELAB (LAB), DIN-99) and calculating color distances based on DIN-99.

README 文档

README

License: MIT Build Status

ColorCompare is a library to convert colors from hex, RGB, HSL, CIE L*a*b* (LAB) and DIN-99 into one another and calculate color distances (human visual difference) using the DIN-99 methedology.

You can get the library from packagist:

composer require fjw/color-compare

How to use

You can get the DIN-99 visual difference (distance) of two colors easily:

use ColorCompare\Color;

$color1 = new Color("#aaff05");
$color2 = new Color("#CCC");

$difference = $color1->getDifference($color2);

You can convert each format into one another:

use ColorCompare\Color;

$color = new Color("#aaff05");

$hex = $color->getHex(); // just to show off, it already was Hex ;)
$rgb = $color->getRgb(); // [ "r" => 170, "g" => 255, "b" => 5 ]
$hsl = $color->getHsl(); // [ "h" => 80.4, "s" => 1.0, "l" => 0.51 ]
$lab = $color->getLab(); // [ "L" => 91.72, "a" => -54.41, "b" => 87.65 ]
$din99 = $color->getDin99(); // [ "L99" => 94.51, "a99" => -12.31, "b99" => 30.39 ]

You can create the color object by Hex, RGB, HSL and LAB:

use ColorCompare\Color;

$color = new Color([
    "h" => 300,
    "s" => 0.5,
    "l" => 1 
]);

$hex = $color->getHex();

Visual Color Distance with DIN-99

DIN-99 differences, returned by Color::getDifference(), can better calculate the human visual difference than LAB with delta-E. There are also superior distance calculations like CIE94 or CIEDE2000 but these are complicated and need intensive calculations. With DIN-99 the calculation is done beforehand and needs less ressources. When your color is already converted into DIN-99 you can just calculate the euklidean distance and get the same quality.

sqrt(($c2["L99"] - $c1["L99"])**2 +
    ($c2["a99"] - $c1["a99"])**2 +
    ($c2["b99"] - $c1["b99"])**2);

This is a huge advantage! If you would like, per example, make a client side filter of colored products (or whatever) you can convert your data into DIN-99 on the server side and only need to do the easier euklidean calculation in your JavaScript.

Sources (german):

http://www.germancolorgroup.de/html/Vortr_02_pdf/GCG_%202002_%20Buering.pdf

https://de.wikipedia.org/wiki/DIN99-Farbraum

Example Code

Just run ./devserver.sh if you have PHP-CLI and open http://localhost:8000 to see the difference calculation in action.

fjw/color-compare 适用场景与选型建议

fjw/color-compare 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 10.84k 次下载、GitHub Stars 达 13, 最近一次更新时间为 2019 年 06 月 03 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「php」 「color」 「distance」 「compare」 「rgb」 「hsl」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 fjw/color-compare 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 fjw/color-compare 我们能提供哪些服务?
定制开发 / 二次开发

基于 fjw/color-compare 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 13
  • Watchers: 2
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-06-03