CSS`hue-rotate`过滤到php

时间:2015-05-01 09:14:06

标签: php css css3 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中同样适用)

1 个答案:

答案 0 :(得分:1)

想象力中的

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

相关问题