Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

PHP ÅжÏÊÇ·ñµÍË×ͼƬ==ÊÇ·ñ@É«@Çé@ͼ@Ƭ

if(validatorImage("d:\b.jpg"))
echo 'ÊǸöµÍË×ͼƬ<br />';
else
echo '²»ÊǵÍË×ͼƬ<br />';
function validatorImage($fileName){
$image = getImage($fileName);
$width = ImagesX($image);
$height = ImagesY($image);
$ycb = 0;
for($y=0;$y<$height;$y++){
for($x=0;$x<$width;$x++){
$rgb = ImageColorAt($image,$x,$y);
$r = ($rgb >> 16) & 0xFF;
$g = ($rgb >> 8) & 0xFF;
$b = $rgb & 0xFF;
$ycbcr = rgb2ycbcr($r,$g,$b);
if((86<=$ycbcr['cb']&&$ycbcr['cb']<=117)&&(140<=$ycbcr['cr']&&$ycbcr['cr']< 168)){
$ycb++;
}
}
}
imagedestroy($image);

if($ycb>(floatval($width)*floatval($height)*0.3))
return true;
else
return false;
}
function getImage($fileName){
$info = getImageSize($fileName);
$ext = null;
switch ($info[2]) {
case 1 :
$ext = "gif";
break;
case 2 :
$ext = "jpeg";
break;
case 3 :
$ext = "png";
break;
}
$function = 'ImageCreatefrom'.ucfirst($ext);
$resource = $function($fileName);
return $resource;
}
// RGB ת YCbCrÉ«²Ê
function rgb2ycbcr($r,$g,$b){
$r = floatval($r);
$g = floatval($g);
$b = floatval($b);

$y = 0.299*$r + 0.587*$g + 0.114*$b;
$cb = (1 / 1.772) * ($b - $y) + 128;
$cr = (1 / 1.402) * ($r - $y) + 128;

return array('y'=>$y,'cb'=>$cb,'cr'=>$cr);
}

˵Ã÷£º
ÉÏÃæÊÇͨ¹ý RGBÉ«²ÊÄ£ÐÍ  ×ª³É YCbCrÉ«²ÊÄ£ÐÍ ÔÚ YCbCrÉ«²ÊÄ£ÐÍ ÅжϵÍË×É«µÄÕ¼±È£¬Èç¹ûÉÌÓû¹Òª¼ÓÉϼ¡·ôÉ«µÄ¹ýÂ˼°¶ÔµÍËײ¿Î»µÄÅжϣ¬ÒÀ¾Ý±ÈÀý¶ÔͼƬ½øÐзÖÀà¡£
YCbCr Ïà¹Ø֪ʶ£¬¿ÉÒԲο¼http://zh.wikipedia.org/wiki/YCbCr
RGB ת³É YCbCr ¹«Ê½¿ÉÒԲο¼http://blog.csdn.net/zyl910/archive/2006/05/29/759535.aspx


Ïà¹ØÎĵµ£º

ÐÖµÜÁ¬ÉçÍÅ——È«¹ú×î´óµÄPHP¼¼ÊõÉçÍÅ

1¡¢ÉçÍżò½é£º
LAMPÐÖµÜÁ¬ÉçÍÅ£¨¼ò³ÆÐÖµÜÁ¬£©ÊÇÒ×µÚÓŽÌÓýѧԺÁ쵼ϵÄÉçÍÅ×éÖ¯£¬ÊÇѧԺÁªÏµ¹ã´óLAMP°®ºÃÕßµÄÇÅÁººÍŦ´ø£¬ÊÇѧԺÉçÍŹÜÀíЭµ÷µÄ»ú¹¹¡£
2¡¢ÉçÍÅÐÔÖÊ£º
ÓÉLAMPÐÖµÜÁ¬·¢Æð£¨www.lampbrother.net£©µÄÈ«¹úרҵÐÔ¡¢¹«ÒæÐÔÉç»áɳÁú×éÖ¯¡£
3¡¢ÉçÍÅÄ¿µÄ£º
a¡¢Îª°®ºÃLAMPµÄÅóÓÑÃǴһ¸öѧϰ½»Á÷µÄƽ̨
b¡¢Îª ......

PHP»ñÈ¡ºº×ÖÆ´ÒôÊ××Öĸ

<FORM METHOD=POST ACTION="#">
<INPUT TYPE="text" NAME="name">
<INPUT TYPE="submit" value="query" name="sub">
</FORM>
<?php
function getinitial($str)
{
$asc=ord(substr($str,0,1)); //ord()»ñÈ¡ASCII
if ($asc<160) //·ÇÖÐÎÄ
{
if ($asc>=48 ......

²é¿´Ò³ÃæÖ´ÐÐphpÕ¼ÓÃÄÚ´æÇé¿ö

½ñÌìÍ·ÄÔÒ»ÈÈ£¬Ïë¿´Ò»ÏÂÒ³ÃæÔÚÖ´ÐеĹý³ÌÖÐÕ¼ÓÃÁ˶àÉÙÄڴ棬ÎÒÒ²²»ÖªµÀÕâÑù×öµÄÄ¿µÄÊÇʲô£¬¿ÉÄÜÊdzöÓÚÎҵĹßÐÔ˼ά°É¡£²»¹ýÕâÑù×öÒ²²»ÊÇÍêȫûÓã¬
Äã¿ÉÒÔÇå³þµÄÖªµÀÄÄЩҳÃæÕ¼ÓõÄÄÚ´æ±È½Ï¶à£¬ÌرðÊǶÔÓÚʹÓù²ÓÃÖ÷»úµÄÍøÕ¾£¬Ò»°ã¿Õ¼äÉ̶¼»áÏÞÖÆÿ¸öÍøÕ¾µÄ×ÊÔ´Õ¼ÓÃÇé¿öµÄ£¨°üÀ¨cpuºÍÄڴ棩¡£ÍòÒ»ÔÚÎÒ
ÃDz»ÖªµÀµÄÇé¿öÏ£ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ