显示下面的内容:
*****************************************
塒NG  IHDR篧?餚LTE潴铗躜筱腧zz|考?,8=%"茨贮筘3<=铈闣U_螋踸|檉M?黛仝佘€懅商覸>6fdw248=0%'[[N0,#倓奩TJ殦w#"IC3Zdv@8+巬x.%! ifa{wi鳚寗* &uhS巺俧]_彁? 沅熠咏HLZL<*{oS>" /$JF@jcR唕v弞expdVE=4:(u灉︸渲 缤篈<7f\NVLBL=6VD1 Warning: Cannot add header information - headers already sent by (output started at /home/wlhyxcao0ss6b7g5o649/wwwroot/cpxl/newgif.php:7) in /home/wlhyxcao0ss6b7g5o649/wwwroot/cpxl/newgif.php on line 32

解决方案 »

  1.   

    <?php
    function makethumb($srcFile,$dstFile,$dstW,$dstH)
     {
        $data=GetImageSize($srcFile);
    switch($data[2])
        {
       case 1:
         $imgsrc=@ImageCreateFromGIF($srcFile);
     break;
       case 2:
         $imgsrc=@ImageCreateFromJPEG($srcFile);
     break;
       case 3:
         $imgsrc=@ImageCreateFromPNG($srcFile);
     break;
     }
    $srcW=ImageSX($imgsrc);
    $srcH=ImageSY($imgsrc);
    $ni=ImageCreate($dstW,$dstH);
    ImageCopyResized($ni,$imgsrc,0,0,0,0,$dstW,$dstH,$srcW,$srcH);
    return ImagePNG($ni);
     }
    Header( "Content-type:image/PNG");
    $img=makethumb("0008.jpg","",20,20);
    echo $img->Image;
    ?>Header( "Content-type:image/PNG");
    放在makethumb上面看看
    <?php 前面不要有换行
    <?php ?>
    外面不要有空白行
    呵呵,我也是php外行
      

  2.   

    <?php
    function makethumb($srcFile,$dstFile,$dstW,$dstH)
     {
        $data=GetImageSize($srcFile);
    switch($data[2])
        {
       case 1:
         $imgsrc=@ImageCreateFromGIF($srcFile);
     break;
       case 2:
         $imgsrc=@ImageCreateFromJPEG($srcFile);
     break;
       case 3:
         $imgsrc=@ImageCreateFromPNG($srcFile);
     break;
     }
    $srcW=ImageSX($imgsrc);
    $srcH=ImageSY($imgsrc);
    $ni=ImageCreate($dstW,$dstH);
    ImageCopyResized($ni,$imgsrc,0,0,0,0,$dstW,$dstH,$srcW,$srcH);
    ImagePNG($ni);
     }Header( "Content-type:image/PNG");
    makethumb("1.jpg","",20,20);
    ?>
    只需要这么多
      

  3.   

    <? $FILENAME="1"; // 生成图片的宽度 
    $RESIZEWIDTH=20; // 生成图片的高度 
    $RESIZEHEIGHT=20; 
    function ResizeImage($im,$maxwidth,$maxheight,$name){ 
        $width = imagesx($im); 
        $height = imagesy($im); 
        if(($maxwidth && $width > $maxwidth) || ($maxheight && $height > $maxheight)){ 
            if($maxwidth && $width > $maxwidth){ 
                $widthratio = $maxwidth/$width; 
                $RESIZEWIDTH=true; 
            } 
            if($maxheight && $height > $maxheight){ 
                $heightratio = $maxheight/$height; 
                $RESIZEHEIGHT=true; 
            } 
            if($RESIZEWIDTH && $RESIZEHEIGHT){ 
                if($widthratio < $heightratio){ 
                    $ratio = $widthratio; 
                }else{ 
                    $ratio = $heightratio; 
                } 
            }elseif($RESIZEWIDTH){ 
                $ratio = $widthratio; 
            }elseif($RESIZEHEIGHT){ 
                $ratio = $heightratio; 
            } 
            $newwidth = $width * $ratio; 
            $newheight = $height * $ratio; 
            if(function_exists("imagecopyresampled")){ 
                  $newim = imagecreatetruecolor($newwidth, $newheight); 
                  imagecopyresampled($newim, $im, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); 
            }else{ 
                $newim = imagecreate($newwidth, $newheight); 
                  imagecopyresized($newim, $im, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); 
            } 
            ImageJpeg ($newim,$name . ".jpg"); 
            ImageDestroy ($newim); 
        }else{ 
            ImageJpeg ($im,$name . ".jpg"); 
        } 
    } if($_FILES['zhaopian_up']['size']){ 
        if($_FILES['zhaopian_up']['type'] == "image/pjpeg"){ 
            $im = imagecreatefromjpeg($_FILES['zhaopian_up']['tmp_name']); 
        }elseif($_FILES['zhaopian_up']['type'] == "image/x-png"){ 
            $im = imagecreatefrompng($_FILES['zhaopian_up']['tmp_name']); 
        }elseif($_FILES['zhaopian_up']['type'] == "image/gif"){ 
            $im = imagecreatefromgif($_FILES['zhaopian_up']['tmp_name']); 
        } 
        if($im){ 
            if(file_exists("$FILENAME.jpg")){ 
                unlink("$FILENAME.jpg"); 
            } 
            ResizeImage($im,$RESIZEWIDTH,$RESIZEHEIGHT,$FILENAME); 
            ImageDestroy ($im); 
        } 
    } ?> 
    <html><body><script language="JavaScript">
    <!--
    function CheckForm(theForm)
    {
    var fileext=theForm.zhaopian_up.value.substring(theForm.zhaopian_up.value.length-4,theForm.zhaopian_up.value.length)
    fileext=fileext.toLowerCase()
    if (!(fileext=='.jpg' || fileext=='.png'))
    {alert("对不起,不正确的照片文件,必须为*.jpg或*.png文件 !");
    theForm.zhaopian_up.focus();
    return false;
    }
    return true;
    }
    // -->
    </SCRIPT>
    <img src="<? echo($FILENAME.".jpg?reload=".rand(0,999999)); ?>"><br><br> <FORM ENCTYPE="multipart/form-data" ACTION="yht4.php" METHOD="POST" onsubmit="return CheckForm(this)">
    <p class="big"> 上传照片:</p>
    <input type="file" name="zhaopian_up" size="20"> <INPUT TYPE="submit" value="上传"></form> 
    </body> 
    </html>