php - CSS `hue-rotate` 过滤器到 php

标签 php css hue css-filters

我正在尝试在 PHP 中应用 css hue-rotate 过滤器结果

目前我正在使用 Imagick php 库,使用 modulateImage 函数来像这样改变色调

function modulateImage($imagePath, $hue, $brightness, $saturation) {
  $imagick = new \Imagick(realpath($imagePath));
  $imagick->modulateImage($brightness, $saturation, $hue);
  header("Content-Type: image/jpg");
  echo $imagick->getImageBlob();
}

但出于某种原因,将 CSS 的 hue-rotate 的相同值应用于 PHP 函数会给我不同的颜色结果,我不确定它们两者中使用的计算/百分比/度数,我希望有人可以解释或为他们提供任何替代方案(主要是 PHP 的替代方案,我发现 CSS 过滤器非常适合我的需求,我只需要在 PHP 中应用相同的方法)

最佳答案

imagick 中的 modulateImage 需要 $hue 的百分比,而 css 需要度数。这是要转换的公式:http://www.imagemagick.org/Usage/color_mods/#modulate_hue
hue_angle = ( modulate_arg - 100 ) * 180/100; modulate_arg = ( hue_angle * 100/180 ) + 100;

关于php - CSS `hue-rotate` 过滤器到 php,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29984288/

相关文章:

html - 自动跨浏览器视觉检查

hadoop - Hadoop表源详细信息

php - 通过将结果保存到文本文件来减少 MySQL 查询

php - 如何从 Active Directory 填充 Apache 服务器中的 REMOTE_USER(SSO 相关)

php - 在表中添加两个属性,然后使用 AS

html - 如何在悬停时创建像 Google +1 按钮这样的微光动画

html - 调整大小时修复页面布局

hadoop - 无法实例化 HiveMetaStoreClient

hadoop - 如何在Hue Cloudera上的Hive中获取下n行

php - 尝试根据 android 应用程序上的值从 mysql 中获取数据