itwmw/color-difference
Composer 安装命令:
composer require itwmw/color-difference
包简介
Color difference:Din99,CIE76,CIE1994,CIEDE2000,CMC l:c
关键字:
README 文档
README
Color Difference
A library for calculating the perceptual difference between colors (∆E).The difference or distance between two colors is a metric of interest in color science. It allows quantified examination of a notion that formerly could only be described with adjectives. Quantification of these properties is of great importance to those whose work is color-critical. Common definitions make use of the Euclidean distance in a device independent color space.
The following measurements are supported:
- Euclidean
- Weighted Euclidean
- DIN99 (2007)
- CIE76 (1976)
- CIE94 (1994)
- CIEDE2000 (2000)
- CMC l:c (1984)
All calculations are performed in either L*a*b* or L*C*H* space (as the metrics prescribe).
Quick Start
This library is available on packagist, like so:
composer require itwmw/color-difference
Usage
The color difference metrics are implemented via the following functions:
- Euclidean RGB
getDifferenceEuclideanRGB(Color $color): float - Euclidean Lab
getDifferenceEuclideanLab(Color $color): float - Weighted Euclidean RGB
getDifferenceWeightedEuclideanRGB(Color $color): float - Din99
getDifferenceDin99(Color $color): float - CIE76:
getDifferenceCIE76(Color $color): float - CIE94:
getDifferenceCIE94(Color $color, CIE94 $type = CIE94::GraphicArts): float - CIEDE2000:
getDifferenceCIEDE2000(Color $color): float - CMC l:c:
getDifferenceCMC(Color $color, CMC $type = CMC::Imperceptibility): float
use Itwmw\ColorDifference\Color; use Itwmw\ColorDifference\Lib\RGB; use Itwmw\ColorDifference\Support\CIE94; use Itwmw\ColorDifference\Support\CMC; $color = new Color(new RGB(255, 183, 255)); $color2 = new Color(new RGB(55, 65, 53)); echo('Din99:' . $color->getDifferenceDin99($color2) . "\n"); echo('CIE76:' . $color->getDifferenceCIE76($color2) . "\n"); echo('CIE94-GraphicArts:' . $color->getDifferenceCIE94($color2, CIE94::GraphicArts) . "\n"); echo('CIE94-Textiles:' . $color->getDifferenceCIE94($color2, CIE94::Textiles) . "\n"); echo('CMC-Acceptability:' . $color->getDifferenceCMC($color2, CMC::Acceptability) . "\n"); echo('CMC-Imperceptibility:' . $color->getDifferenceCMC($color2, CMC::Imperceptibility) . "\n"); echo('CIEDE2000:' . $color->getDifferenceCIEDE2000($color2) . "\n"); echo('Euclidean RGB:' . $color->getDifferenceEuclideanRGB($color2) . "\n"); echo('Euclidean Lab:' . $color->getDifferenceEuclideanLab($color2) . "\n"); echo('Weighted Euclidean RGB:' . $color->getDifferenceWeightedEuclideanRGB($color2) . "\n");
CIE94 and CMC l:c accept an optional parameter adjusting the metric for the kind of quasimetric being evaluated. CIE94 offers an application type choice of either 'graphicArts' or 'textiles' for their eponymous use. CMC l:c offers a threshold choice of either 'acceptability' or 'imperceptibility' that nuances the just-noticeable difference between the colors.
Reference White
Use referenceWhite to specify Reference White for the Color class
Support:
- A; //Incandescent/tungsten
- B; //Old direct sunlight at noon
- C; //Old daylight
- D50; //ICC profile PCS
- D55; //Mid-morning daylight
- D65; //Daylight, sRGB, Adobe-RGB
- D75; //North sky daylight
- E; //Equal energy
- F1; //Daylight Fluorescent
- F2; //Cool fluorescent
- F3; //White Fluorescent
- F4; //Warm White Fluorescent
- F5; //Daylight Fluorescent
- F6; //Lite White Fluorescent
- F7; //Daylight fluorescent, D65 simulator
- F8; //Sylvania F40, D50 simulator
- F9; //Cool White Fluorescent
- F10; //Ultralume 50, Philips TL85
- F11; //Ultralume 40, Philips TL84
- F12; //Ultralume 30, Philips TL83
new Color(new RGB(255, 183, 255), referenceWhite: ReferenceWhite::D65);
RGB Working Space
Use RGBSpace to specify RGB Working Space for the Color class
Support:
- Adobe RGB (1998)
- AppleRGB
- Best RGB
- Beta RGB
- Bruce RGB
- CIE RGB
- ColorMatch RGB
- Don RGB 4
- ECI RGB
- Ekta Space PS5
- NTSC RGB
- PAL/SECAM RGB
- ProPhoto RGB
- SMPTE-C RGB
- sRGB
- Wide Gamut RGB
new Color(new RGB(255, 183, 255), RGBSpace: RGBSpace::sRGB_D65);
In general,
RGB Working Spaceneeds to correspond toReference White.
The default is:
new Color(new RGB(255, 183, 255), referenceWhite: ReferenceWhite::D65, RGBSpace: RGBSpace::sRGB_D65);
itwmw/color-difference 适用场景与选型建议
itwmw/color-difference 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 8.9k 次下载、GitHub Stars 达 17, 最近一次更新时间为 2022 年 01 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「CIEDE2000」 「din99」 「cie76」 「cie94」 「色差」 「color difference」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 itwmw/color-difference 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 itwmw/color-difference 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 itwmw/color-difference 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
An image and color manipulation and processing library for PHP
A library for converting colors (Hex, RGB, HSL, CIELAB (LAB), DIN-99) and calculating color distances based on DIN-99.
Simple PHP class for automated coloring with visually distinct colors
统计信息
- 总下载量: 8.9k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 17
- 点击次数: 12
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2022-01-13