我有一个jpg图像.
我需要知道"整体平均"的图像颜色.乍一看,可以使用图像的直方图(通道RGB).
在工作中我主要使用JavaScript和PHP(一点点Python)因此欢迎这些语言的决定.也许是用于处理解决类似问题的图像的库.
我不需要动态确定图片的颜色.我只需要浏览整个图像阵列并分别确定每种图像的颜色(这些信息我将记住以备将来使用).
我还没有找到一个很好的例子,说明如何使用php RegexIterator递归遍历目录.
最终的结果是我想指定一个目录并查找其中包含一些给定扩展名的所有文件.比如说只有html/php扩展名.此外,我想过滤掉.Trash-0,.Trash-500等类型的文件夹.
<?php
$Directory = new RecursiveDirectoryIterator("/var/www/dev/");
$It = new RecursiveIteratorIterator($Directory);
$Regex = new RegexIterator($It,'/^.+\.php$/i',RecursiveRegexIterator::GET_MATCH);
foreach($Regex as $v){
echo $value."<br/>";
}
?>
Run Code Online (Sandbox Code Playgroud)
到目前为止我得到的结果是:致命错误:带有消息'RecursiveDirectoryIterator :: __ construct(/media/hdmovies1/.Trash-0)的未捕获异常'UnexpectedValueException'
有什么建议?
以下代码加载在指定文件夹中找到的所有.php文件(单独定义).有没有办法将其放入数组以简化代码?
只有几个变量发生了变化,但基本上代码重复了几次.
// The General Files
$the_general = opendir(FRAMEWORK_GENERAL);
while (($the_general_files = readdir($the_general)) !== false) {
if(strpos($the_general_files,'.php')) {
include_once(FRAMEWORK_GENERAL . $the_general_files);
}
}
closedir($the_general);
// The Plugin Files
$the_plugins = opendir(FRAMEWORK_PLUGINS);
while (($the_plugins_files = readdir($the_plugins)) !== false) {
if(strpos($the_plugins_files,'.php')) {
include_once(FRAMEWORK_PLUGINS . $the_plugins_files);
}
}
closedir($the_plugins);
Run Code Online (Sandbox Code Playgroud)
还有几个部分调用不同的文件夹.
任何帮助是极大的赞赏.
干杯,詹姆斯