PHP 板


LINE

看板 PHP  RSS
以下程式码不是我自己写的 所以自己一知半解...... 想修改也修得乱七八糟兼头大....... 输出到excel这边有试过加上 header("Content-type:application/vnd.ms-excel"); header("Content-Disposition:filename=php_excel.xls"); 这类的方式 但是就只会把网页所显示的图档和文字 (亮度调校 对比调校...等等) http://ppt.cc/KROa 直接贴在excel的工作表上 数值资料也都没有出现 是希望可以改成一次处理多张图档 也能把得到的阈值输出到excel(数字或文字会待在栏位中) 实在是不知道要用甚麽方式解决这个问题 希望有高手能解惑~~~ 谢谢 QQ <?php error_reporting(E_ERROR);header("Content-Type: text/html; charset=utf-8"); if (!is_null($_GET['f'])) { $file = $_GET['f']; } else { $file = "2011_0802_1100"; } if (!is_null($_GET['x'])) { $x = $_GET['x']; } else { $x = 400; } if (!is_null($_GET['y'])) { $y = $_GET['y']; } else { $y = 695; } if (!is_null($_GET['cx'])) { $cx = $_GET['cx']; } else { $cx = 460; } if (!is_null($_GET['cy'])) { $cy = $_GET['cy']; } else { $cy = 125; } if (!is_null($_GET['br'])) { $brightness = $_GET['br']; } else { $brightness = 0; } if (!is_null($_GET['ct'])) { $constrast = $_GET['ct']; } else { $constrast = 0; } if (!is_null($_GET['cr'])) { $cr = $_GET['cr']; } else { $cr = 0; } if (!is_null($_GET['cg'])) { $cg = $_GET['cg']; } else { $cg = 0; } if (!is_null($_GET['cb'])) { $cb = $_GET['cb']; } else { $cb = 0; } $filename = "img/" . $file . ".jpg"; #echo $filename . "\n"; $imInfo = getimagesize($filename); $w = $imInfo[0]; $h = $imInfo[1]; $src = imagecreatefromjpeg($filename); $dst = imagecreatefromjpeg($filename); $msk = imagecreatefrompng("mask.PNG"); imagefilter($msk, IMG_FILTER_NEGATE); #header("Content-Type: image/png"); #imagepng($msk); #return 0; imagefilter($dst, IMG_FILTER_COLORIZE, $cr, $cg, $cb); imagefilter($dst, IMG_FILTER_CONTRAST, $constrast); imagefilter($dst, IMG_FILTER_BRIGHTNESS, $brightness); #imagefilter($msk, IMG_FILTER_COLORIZE, $cr, $cg, $cb); #imagefilter($msk, IMG_FILTER_CONTRAST, $constrast); #imagefilter($msk, IMG_FILTER_BRIGHTNESS, $brightness); #imagecopy($dst, $src, 0, 0, $x, $y, $cx, $cy); imagecopy($dst, $msk, 0, 0, $x, $y, $cx, $cy); imagecopy($dst, $src, 0, $cy, $x, $y, $cx, $cy); $black = imagecolorallocate($dst, 0, 0, 0); $white = imagecolorallocate($dst, 255, 255, 255); $blue = imagecolorallocate($dst, 0, 0, 255); $red = imagecolorallocate($dst, 255, 0, 0); $th = 60; $r=0; $g=0; $b=0; $sqr=0; $sqg=0; $sqb=0; for ($j=0;$j<$cy;$j++) { for ($i=0;$i<$cx;$i++) { $test = imagecolorat($dst, $i, $j); $trgb = imagecolorsforindex($dst, $test); if (($trgb['red']!==0)||($trgb['green']!==0)||($trgb['blue']!==0)) { $am[$i][$j]=FALSE; } else { $am[$i][$j]=TRUE; } } } $pCounter = 0; for ($j=0;$j<$cy;$j++) { for ($i=0;$i<$cx;$i++) { # $test = imagecolorat($dst, $i, $j); # $trgb = imagecolorsforindex($dst, $test); # echo "$i $j\n"; # echo $trgb['red'] . "," . $trgb['green'] . "," . $trgb['blue'] . "\n"; # if (($trgb['red']!==0)||($trgb['green']!==0)||($trgb['blue']!==0)) { # continue; # } # var_dump($test); if ($am[$i][$j]===FALSE) { continue; } $pCounter++; $colorIndex = imagecolorat($dst, $i+$x, $j+$y); $rgba = imagecolorsforindex($dst, $colorIndex); $r += $rgba['red']; $g += $rgba['green']; $b += $rgba['blue']; $sqr+= pow($rgba['red'],2); $sqg+= pow($rgba['green'],2); $sqb+= pow($rgba['blue'],2); # if (($r<=$th)||($g<=$th)||($b<=$th)) { # echo "black\n"; # imagesetpixel($im, $x, $y, $black); # } # else { # echo "white\n"; # imagesetpixel($im, $x, $y, $white); # } # $progress = 100 * ($y * $w + $x) / ($w * $h); # $progress = sprintf("%f%%\r", $progress); # echo $progress; } } $ar = ($r/$pCounter); $ag = ($g/$pCounter); $ab = ($b/$pCounter); $sdr = (sqrt(($sqr / $pCounter) - pow($ar,2))); $sdg = (sqrt(($sqg / $pCounter) - pow($ag,2))); $sdb = (sqrt(($sqb / $pCounter) - pow($ab,2))); if (!is_null($_GET['thr'])) { $thr = $_GET['thr']; } else { $thr = $ar; } if (!is_null($_GET['thg'])) { $thg = $_GET['thg']; } else { $thg = $ag; } if (!is_null($_GET['thb'])) { $thb = $_GET['thb']; } else { $thb = $ab; } /* if (($ab > 40)&&($sdr > 50)) { $thr = $ar + 1.5*$sdr; $thg = $ag + 1.5*$sdg; $thb = $ab + 1.8*$sdb; } else if (($ab > 40)&&($sdr <= 50)) { $thr = $ar + 3 * $sdr; $thg = $ag + 1.5*$sdg; $thb = $ab + 1.5*$sdb; } else { $thr = $ar; $thg = $ag; $thb = $ab; } */ for ($j=0;$j<$cy;$j++) { for ($i=0;$i<$cx;$i++) { if ($am[$i][$j]===FALSE) { continue; } $colorIndex = imagecolorat($dst, $i+$x, $j+$y); $rgba = imagecolorsforindex($dst, $colorIndex); $r = $rgba['red']; $g = $rgba['green']; $b = $rgba['blue']; if (($r<=$thr)||($g<=$thg)||($b<=$thb)) { # echo "black\n"; imagesetpixel($dst, $i, $j, $black); } else { # echo "white\n"; imagesetpixel($dst, $i, $j, $white); } # $progress = 100 * ($y * $w + $x) / ($w * $h); # $progress = sprintf("%f%%\r", $progress); # echo $progress; } } $string1 = "ar=$ar, ag=$ag, ab=$ab"; $string2 = "sdr=$sdr, sdg=$sdg, sdb=$sdb"; imagestring($dst, 20, 0, 250, $string1, $black); imagestring($dst, 20, 0, 275, $string2, $black); imagestring($dst, 20, 5, 105, "Target", $red); imagestring($dst, 20, 5, 230, "Original", $red); #header('Content-Type: image/png'); exec("rm -f tmp/fog_*.png"); imagepng($dst, "tmp/fog" . $file . ".png", 0); $fs = filesize("tmp/fog" . $file . ".png"); while ($fs != filesize("tmp/fog" . $file . ".png")) { sleep(0.1); $fs = filesize("tmp/fog" . $file . ".png"); } #echo $string; #echo "<img src='tmp.png' />"; imagedestroy($msk); imagedestroy($src); imagedestroy($dst); echo "<html>\n"; echo "\t<head>\n"; echo "\t</head>\n"; echo "\t<body>\n"; echo "<table><tr>"; echo "<th>"; echo "\t\t<img width=\"100%\" src=\"" . "tmp/fog" . $file . ".png" . "\"/>\n"; echo "</th>"; echo "<td>"; echo "<form name=\"test\">"; echo "<table><tr>"; echo "<th>档案名称</th><td><input type=\"text\" name=\"f\" value=\"$file\"/></td>"; echo "</tr><tr>"; echo "<th>亮度调校</th><td><input type=\"text\" name=\"br\" value=\"$brightness\"/></td>"; echo "</tr><tr>"; echo "<th>对比调校</th><td><input type=\"text\" name=\"ct\" value=\"$constrast\"/></td>"; echo "</tr><tr>"; echo "<th>红光滤镜</th><td><input type=\"text\" name=\"cr\" value=\"$cr\"/></td>"; echo "</tr><tr>"; echo "<th>绿光滤镜</th><td><input type=\"text\" name=\"cg\" value=\"$cg\"/></td>"; echo "</tr><tr>"; echo "<th>蓝光滤镜</th><td><input type=\"text\" name=\"cb\" value=\"$cb\"/></td>"; echo "</tr><tr>"; echo "<th>红光阈值</th><td><input type=\"text\" name=\"thr\" value=\"$thr\"/></td>"; echo "</tr><tr>"; echo "<th>绿光阈值</th><td><input type=\"text\" name=\"thg\" value=\"$thg\"/></td>"; echo "</tr><tr>"; echo "<th>蓝光阈值</th><td><input type=\"text\" name=\"thb\" value=\"$thb\"/></td>"; echo "</tr><tr>"; echo "<th></th><td><input type=\"submit\" name=\"submit\"/></td>"; echo "</tr>"; echo "</form>"; echo "</td>"; echo "</table>"; echo "\t</body>\n"; echo "</html>"; return 0; --



※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 111.248.130.7 ※ 编辑: chousf 来自: 111.248.130.7 (05/31 00:01)
1F:→ MOONRAKER:一般网页转成xls下载也就是如此 05/31 04:24
2F:→ MOONRAKER:mime type设对,输出HTML,自然可以伪装成xls 05/31 04:24
3F:→ MOONRAKER:你要检查你输出的xls到底有没有包含网页上的资讯 05/31 04:25
4F:→ MOONRAKER:很可能一开始就漏掉了 05/31 04:25







like.gif 您可能会有兴趣的文章
icon.png[问题/行为] 猫晚上进房间会不会有憋尿问题
icon.pngRe: [闲聊] 选了错误的女孩成为魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一张
icon.png[心得] EMS高领长版毛衣.墨小楼MC1002
icon.png[分享] 丹龙隔热纸GE55+33+22
icon.png[问题] 清洗洗衣机
icon.png[寻物] 窗台下的空间
icon.png[闲聊] 双极の女神1 木魔爵
icon.png[售车] 新竹 1997 march 1297cc 白色 四门
icon.png[讨论] 能从照片感受到摄影者心情吗
icon.png[狂贺] 贺贺贺贺 贺!岛村卯月!总选举NO.1
icon.png[难过] 羡慕白皮肤的女生
icon.png阅读文章
icon.png[黑特]
icon.png[问题] SBK S1安装於安全帽位置
icon.png[分享] 旧woo100绝版开箱!!
icon.pngRe: [无言] 关於小包卫生纸
icon.png[开箱] E5-2683V3 RX480Strix 快睿C1 简单测试
icon.png[心得] 苍の海贼龙 地狱 执行者16PT
icon.png[售车] 1999年Virage iO 1.8EXi
icon.png[心得] 挑战33 LV10 狮子座pt solo
icon.png[闲聊] 手把手教你不被桶之新手主购教学
icon.png[分享] Civic Type R 量产版官方照无预警流出
icon.png[售车] Golf 4 2.0 银色 自排
icon.png[出售] Graco提篮汽座(有底座)2000元诚可议
icon.png[问题] 请问补牙材质掉了还能再补吗?(台中半年内
icon.png[问题] 44th 单曲 生写竟然都给重复的啊啊!
icon.png[心得] 华南红卡/icash 核卡
icon.png[问题] 拔牙矫正这样正常吗
icon.png[赠送] 老莫高业 初业 102年版
icon.png[情报] 三大行动支付 本季掀战火
icon.png[宝宝] 博客来Amos水蜡笔5/1特价五折
icon.pngRe: [心得] 新鲜人一些面试分享
icon.png[心得] 苍の海贼龙 地狱 麒麟25PT
icon.pngRe: [闲聊] (君の名は。雷慎入) 君名二创漫画翻译
icon.pngRe: [闲聊] OGN中场影片:失踪人口局 (英文字幕)
icon.png[问题] 台湾大哥大4G讯号差
icon.png[出售] [全国]全新千寻侘草LED灯, 水草

请输入看板名称,例如:Soft_Job站内搜寻

TOP