缩图成黑的不知道为什么,不过你把GIF的文件直接改名成jpg在WINDOWS下也能正常显示
不过文件头信息并没有改,所以处理的时候出错

解决方案 »

  1.   

    發個代碼給你吧!
    //*************upload.php*******************
    if(empty($upfile)){ 
    print("No file was transfered!n沒有文件"); 
    exit; 

    $image_path=$upfile;//上頁傳過來的圖片名字
    $image_info=getimagesize($image_path); 
    if($image_info[2]==2) 
    {$image2=imagecreatefromjpeg($image_path); 

    else if($image_info[2]==1){ 
    $image2=imagecreatefromgif($image_path); 

    else{print("祥諉忳腔芞ㄐ");exit;} 
    if(empty($image2)){print("炵苀渣昫ㄛ笭彸");exit;} 
    $image2_x=imagesx($image2); 
    $image2_y=imagesy($image2); 
    if($image2_x==$image2_y){ 
    $x=150; 
    $y=0; 

    else if($image2_x>$image2_y){ 
    $x=150; 
    $y=intval(150*$image2_y/$image2_x); 

    else{ 
    $y=150; 
    $x=intval(150*$image2_x/$image2_y); 

    $image1=imagecreatetruecolor($x,$y); 
    imagecopyresized($image1,$image2,0,0,0,0,$x,$y,$image2_x,$image2_y); 
    $Img = imagejpeg($image1);
    //***********************************************************
    因為在繫體底下。一些中文沒辦法顯示了。也差不多這個意思。你把代碼考過去。然后用如下調用:
    <img src="../upload.php?file=admin/<?=$StrPath?>" border="0" width="110">在這里width不設也可以。
      

  2.   

    還有圖片最好設為RGB格式。php里的GD庫要裝。回答完畢
      

  3.   

    GD库2.0.1以上才能使用imagecreatetruecolor和imagecopyresampled(imagecopyresampled比imagecopyresized生成图像的品质好很多,但需要GD2支持)把
    $dst_im=imagecreatetruecolor($dstx,$dsty);$src_im=imagecreatefromjpeg($targetpath."/".$newfilename);imageCopyResampled($dst_im,$src_im,0,0,0,0,$dstx,$dsty,$scr_size[0],$scr_size[1]);改为这样写可以兼容GD1$dst_im=(function_exists(imagecreatetruecolor))?imagecreatetruecolor($dstx,$dsty):imagecreate($dstx,$dsty);$src_im=imagecreatefromjpeg($targetpath."/".$newfilename);(function_exists(imagecreatetruecolor))?imageCopyResampled($dst_im,$src_im,0,0,0,0,$dstx,$dsty,$scr_size[0],$scr_size[1]):imagecopyresized($dst_im,$src_im,0,0,0,0,$dstx,$dsty,$scr_size[0],$scr_size[1]);
      

  4.   

    不好意思
    最后一行改成
    (function_exists(imageCopyResampled))?imageCopyResampled($dst_im,$src_im,0,0,0,0,$dstx,$dsty,$scr_size[0],$scr_size[1]):imagecopyresized($dst_im,$src_im,0,0,0,0,$dstx,$dsty,$scr_size[0],$scr_size[1]);
      

  5.   

    另外,imagecreatetruecolor和imagecopyresampled这几个函数我这里可以用的,装的就是GD2
      

  6.   

    程序没有问题,可能GD有问题,试试
    换个GD | 重装php
      

  7.   

    偶的
    PHP Version 5.1.1 Apache/2.2.0 (Win32)gd_info()Array
    (
        [GD Version] => bundled (2.0.28 compatible)
        [FreeType Support] => 1
        [FreeType Linkage] => with freetype
        [T1Lib Support] => 1
        [GIF Read Support] => 1
        [GIF Create Support] => 1
        [JPG Support] => 1
        [PNG Support] => 1
        [WBMP Support] => 1
        [XPM Support] => 
        [XBM Support] => 1
        [JIS-mapped Japanese Font Support] => 
    )
      

  8.   

    最后还是改用magickwand来做缩略图了,多谢楼上各位