【问题标题】:php resize image on uploadphp在上传时调整图像大小
【发布时间】:2013-09-19 06:34:03
【问题描述】:

我得到一个表单,用户在其中插入一些数据并上传图像。

为了处理图像,我得到了以下代码:

define("MAX_SIZE", "10000");
$errors = 0;
$image = $_FILES["fileField"]["name"];
$uploadedfile = $_FILES['fileField']['tmp_name'];
if($image){
    $filename = stripslashes($_FILES['fileField']['name']);
    $extension = strtolower(getExtension($filename));
    if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")){
        echo ' Unknown Image extension ';
        $errors = 1;
    } else {
        $newname = "$product_cn.$extension";
        $size = filesize($_FILES['fileField']['tmp_name']);
        if ($size > MAX_SIZE*1024){
            echo "You have exceeded the size limit";
            $errors = 1;
        }
        if($extension == "jpg" || $extension == "jpeg" ){
            $uploadedfile = $_FILES['file']['tmp_name'];
            $src = imagecreatefromjpeg($uploadedfile);
        } else if($extension == "png"){
            $uploadedfile = $_FILES['file']['tmp_name'];
            $src = imagecreatefrompng($uploadedfile);
        } else {
            $src = imagecreatefromgif($uploadedfile);
        }
        list($width, $height) = getimagesize($uploadedfile);
        $newwidth = 60;
        $newheight = ($height/$width)*$newwidth;
        $tmp = imagecreatetruecolor($newwidth, $newheight);
        $newwidth1 = 25;
        $newheight1 = ($height/$width)*$newwidth1;
        $tmp1 = imagecreatetruecolor($newwidth1, $newheight1);
        imagecopyresampled($tmp, $src, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
        imagecopyresampled($tmp1, $src, 0, 0, 0, 0, $newwidth1, $newheight1, $width, $height);
        $filename = "../products_images/$newname";
        $filename1 = "../products_images/thumbs/$newname";
        imagejpeg($tmp, $filename, 100); // file name also indicates the folder where to save it to
        imagejpeg($tmp1, $filename1, 100);
        imagedestroy($src);
        imagedestroy($tmp);
        imagedestroy($tmp1);
    }
}

getExtension函数:

function getExtension($str) {
    $i = strrpos($str, ".");
    if (!$i) { return ""; }
    $l = strlen($str) - $i;
    $ext = substr($str,$i+1,$l);
    return $ext;
}

我在代码中写了一些符号,因为我不太熟悉这些函数。

由于某种原因,它不起作用。当我去文件夹“product_images”或“product_images/thumbs”时,我找不到任何上传的图片。

知道我的代码有什么问题吗?应该有 60px 宽度的图片和 25px 宽度的图片。

注意:您不知道它们在哪里声明的变量,例如$product_cn,是在该代码块之前声明的,该代码块运行良好(经过测试)。如果您还想看一眼,请随时索取代码。

提前致谢!

【问题讨论】:

    标签: php image


    【解决方案1】:

    这是另一个不错且简单的解决方案:

    $maxDim = 800;
    $file_name = $_FILES['myFile']['tmp_name'];
    list($width, $height, $type, $attr) = getimagesize( $file_name );
    if ( $width > $maxDim || $height > $maxDim ) {
        $target_filename = $file_name;
        $ratio = $width/$height;
        if( $ratio > 1) {
            $new_width = $maxDim;
            $new_height = $maxDim/$ratio;
        } else {
            $new_width = $maxDim*$ratio;
            $new_height = $maxDim;
        }
        $src = imagecreatefromstring( file_get_contents( $file_name ) );
        $dst = imagecreatetruecolor( $new_width, $new_height );
        imagecopyresampled( $dst, $src, 0, 0, 0, 0, $new_width, $new_height, $width, $height );
        imagedestroy( $src );
        imagepng( $dst, $target_filename ); // adjust format as needed
        imagedestroy( $dst );
    }
    

    参考:PHP resize image proportionally with max width or weight

    编辑:清理并简化了代码。感谢@jan-mirus 的评论。

    【讨论】:

    • 它有效,但我很困惑 - 为什么要提取两次图像尺寸?
    • 这太棒了。虽然它最后缺少了一个非常重要的行:move_uploaded_file($_FILES['myFile']['tmp_name'], $destinationFilePath);
    • @jan-mirus 公元前,宽度和高度变量在中间发生了变化。它不漂亮,现在应该更容易阅读了。
    • 有人能解释一下图像文件发送到哪里吗?我好像找不到?我基本上想要调整大小的图像并插入数据库。我在想象它的 $target_filename,但我已经达到了我的知识极限。
    【解决方案2】:

    您可以在上传时使用此库来操作图像。 http://www.verot.net/php_class_upload.htm

    【讨论】:

    • 警告:该脚本在 GPL 下,因此您需要购买商业版本(15 美元)或在 GPL 下打开您的网站源代码。
    【解决方案3】:

    // 这是我的示例,我曾经将每张插入的照片自动调整为 100 x 50 像素,并将图像格式调整为 jpeg,希望这也有帮助

    if($result){
    $maxDimW = 100;
    $maxDimH = 50;
    list($width, $height, $type, $attr) = getimagesize( $_FILES['photo']['tmp_name'] );
    if ( $width > $maxDimW || $height > $maxDimH ) {
        $target_filename = $_FILES['photo']['tmp_name'];
        $fn = $_FILES['photo']['tmp_name'];
        $size = getimagesize( $fn );
        $ratio = $size[0]/$size[1]; // width/height
        if( $ratio > 1) {
            $width = $maxDimW;
            $height = $maxDimH/$ratio;
        } else {
            $width = $maxDimW*$ratio;
            $height = $maxDimH;
        }
        $src = imagecreatefromstring(file_get_contents($fn));
        $dst = imagecreatetruecolor( $width, $height );
        imagecopyresampled($dst, $src, 0, 0, 0, 0, $width, $height, $size[0], $size[1] );
    
        imagejpeg($dst, $target_filename); // adjust format as needed
    
    
    }
    
    move_uploaded_file($_FILES['pdf']['tmp_name'],"pdf/".$_FILES['pdf']['name']);
    

    【讨论】:

    • 虽然此代码可能有助于解决问题,但它并没有解释为什么和/或如何回答问题。提供这种额外的背景将显着提高其长期教育价值。请edit您的答案添加解释,包括适用的限制和假设。
    • 最佳答案 - 不需要任何库! move_uploaded_file - 应该被删除,因为 imagejpeg 将文件移动到新的目标 $target_filename
    【解决方案4】:
    <form action="<?php echo $_SERVER["PHP_SELF"];  ?>" method="post" enctype="multipart/form-data" id="something" class="uniForm">
        <input name="new_image" id="new_image" size="30" type="file" class="fileUpload" />
        <button name="submit" type="submit" class="submitButton">Upload Image</button>
    </form>
    
    <?php
        if(isset($_POST['submit'])){
          if (isset ($_FILES['new_image'])){              
              $imagename = $_FILES['new_image']['name'];
              $source = $_FILES['new_image']['tmp_name'];
              $target = "images/".$imagename;
              $type=$_FILES["new_image"]["type"];
    
              if($type=="image/jpeg" || $type=="image/jpg"){
              move_uploaded_file($source, $target);
              //orginal image making part
    
              $imagepath = $imagename;
              $save = "images/" . $imagepath; //This is the new file you saving
              $file = "images/" . $imagepath; //This is the original file
              list($width, $height) = getimagesize($file) ;
              $modwidth = 1000;
              $diff = $width / $modwidth;
              $modheight = $height / $diff;   
              $tn = imagecreatetruecolor($modwidth, $modheight) ;
              $image = imagecreatefromjpeg($file) ;
              imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;
              echo "Large image: <img src='images/".$imagepath."'><br>";                     
              imagejpeg($tn, $save, 100) ;
    
              //thumbnail image making part
              $save = "images/thumb/" . $imagepath; //This is the new file you saving
              $file = "images/" . $imagepath; //This is the original file   
              list($width, $height) = getimagesize($file) ;
              $modwidth = 150;
              $diff = $width / $modwidth;
              $modheight = $height / $diff;
              $tn = imagecreatetruecolor($modwidth, $modheight) ;
              $image = imagecreatefromjpeg($file) ;
              imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;
            //echo "Thumbnail: <img src='images/sml_".$imagepath."'>";
              imagejpeg($tn, $save, 100) ;
              }
            else{
                echo "File is not image";
                }
          }
        }
    ?>
    

    【讨论】:

    • 不要用公认的答案回答多年的问题,而是尝试回答没有答案的新问题
    • 当我上传尺寸为 300X200 的图像时,它会将其转换为 1000 宽度。当图像大小大于 $modwidth 1000 时,它应该转换。我该怎么做?
    • @AnuraagBaishya 你不应该那样说。他的回答帮助了我,节省了我太多的时间
    【解决方案5】:

    基于@zeusstl 的回答,上传多张图片:

    function img_resize()
    {
    
      $input = 'input-upload-img1'; // Name of input
    
      $maxDim = 400;
      foreach ($_FILES[$input]['tmp_name'] as $file_name){
        list($width, $height, $type, $attr) = getimagesize( $file_name );
        if ( $width > $maxDim || $height > $maxDim ) {
            $target_filename = $file_name;
            $ratio = $width/$height;
            if( $ratio > 1) {
                $new_width = $maxDim;
                $new_height = $maxDim/$ratio;
            } else {
                $new_width = $maxDim*$ratio;
                $new_height = $maxDim;
            }
            $src = imagecreatefromstring( file_get_contents( $file_name ) );
            $dst = imagecreatetruecolor( $new_width, $new_height );
            imagecopyresampled( $dst, $src, 0, 0, 0, 0, $new_width, $new_height, $width, $height );
            imagedestroy( $src );
            imagepng( $dst, $target_filename ); // adjust format as needed
            imagedestroy( $dst );
        }
      }
    }
    

    【讨论】:

      【解决方案6】:

      如果您想开箱即用地使用 Imagick(大多数 PHP 发行版都包含),它就像...

      $image = new Imagick();
      $image_filehandle = fopen('some/file.jpg', 'a+');
      $image->readImageFile($image_filehandle);
      
      $image->scaleImage(100,200,FALSE);
      
      $image_icon_filehandle = fopen('some/file-icon.jpg', 'a+');
      $image->writeImageFile($image_icon_filehandle);
      

      您可能希望根据原始图像更动态地计算宽度和高度。您可以使用上面的示例获取图像的当前宽度和高度,使用 $image-&gt;getImageHeight();$image-&gt;getImageWidth();

      【讨论】:

        【解决方案7】:

        这件事对我有用。 没有使用任何外部库

            define ("MAX_SIZE","3000");
         function getExtension($str) {
                 $i = strrpos($str,".");
                 if (!$i) { return ""; }
                 $l = strlen($str) - $i;
                 $ext = substr($str,$i+1,$l);
                 return $ext;
         }
        
         $errors=0;
        
         if($_SERVER["REQUEST_METHOD"] == "POST")
         {
            $image =$_FILES["image-1"]["name"];
            $uploadedfile = $_FILES['image-1']['tmp_name'];
        
        
            if ($image) 
            {
        
                $filename = stripslashes($_FILES['image-1']['name']);
        
                $extension = getExtension($filename);
                $extension = strtolower($extension);
        
        
         if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")) 
                {
                    echo "Unknown Extension..!";
                }
                else
                {
        
         $size=filesize($_FILES['image-1']['tmp_name']);
        
        
        if ($size > MAX_SIZE*1024)
        {
            echo "File Size Excedeed..!!";
        }
        
        
        if($extension=="jpg" || $extension=="jpeg" )
        {
        $uploadedfile = $_FILES['image-1']['tmp_name'];
        $src = imagecreatefromjpeg($uploadedfile);
        
        }
        else if($extension=="png")
        {
        $uploadedfile = $_FILES['image-1']['tmp_name'];
        $src = imagecreatefrompng($uploadedfile);
        
        }
        else 
        {
        $src = imagecreatefromgif($uploadedfile);
        echo $scr;
        }
        
        list($width,$height)=getimagesize($uploadedfile);
        
        
        $newwidth=1000;
        $newheight=($height/$width)*$newwidth;
        $tmp=imagecreatetruecolor($newwidth,$newheight);
        
        
        $newwidth1=1000;
        $newheight1=($height/$width)*$newwidth1;
        $tmp1=imagecreatetruecolor($newwidth1,$newheight1);
        
        imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
        
        imagecopyresampled($tmp1,$src,0,0,0,0,$newwidth1,$newheight1,$width,$height);
        
        
        $filename = "../images/product-image/Cars/". $_FILES['image-1']['name'];
        
        $filename1 = "../images/product-image/Cars/small". $_FILES['image-1']['name'];
        
        
        
        imagejpeg($tmp,$filename,100);
        
        imagejpeg($tmp1,$filename1,100);
        
        imagedestroy($src);
        imagedestroy($tmp);
        imagedestroy($tmp1);
        }}
        
        }
        

        【讨论】:

          【解决方案8】:

          您也可以使用 Imagine 库。它使用 GD 和 Imagick。

          【讨论】:

            【解决方案9】:

            index.php:

            <!DOCTYPE html>
            <html>
            <head>
                <title>PHP Image resize to upload</title>
            </head>
            <body>
            
            
            <div class="container">
                <form action="pro.php" method="post" enctype="multipart/form-data">
                    <input type="file" name="image" /> 
                    <input type="submit" name="submit" value="Submit" />
                </form>
            </div>
            
            
            </body>
            </html>
            

            上传.php

            <?php
            
            
            if(isset($_POST["submit"])) {
                if(is_array($_FILES)) {
            
            
                    $file = $_FILES['image']['tmp_name']; 
                    $sourceProperties = getimagesize($file);
                    $fileNewName = time();
                    $folderPath = "upload/";
                    $ext = pathinfo($_FILES['image']['name'], PATHINFO_EXTENSION);
                    $imageType = $sourceProperties[2];
            
            
                    switch ($imageType) {
            
            
                        case IMAGETYPE_PNG:
                            $imageResourceId = imagecreatefrompng($file); 
                            $targetLayer = imageResize($imageResourceId,$sourceProperties[0],$sourceProperties[1]);
                            imagepng($targetLayer,$folderPath. $fileNewName. "_thump.". $ext);
                            break;
            
            
                        case IMAGETYPE_GIF:
                            $imageResourceId = imagecreatefromgif($file); 
                            $targetLayer = imageResize($imageResourceId,$sourceProperties[0],$sourceProperties[1]);
                            imagegif($targetLayer,$folderPath. $fileNewName. "_thump.". $ext);
                            break;
            
            
                        case IMAGETYPE_JPEG:
                            $imageResourceId = imagecreatefromjpeg($file); 
                            $targetLayer = imageResize($imageResourceId,$sourceProperties[0],$sourceProperties[1]);
                            imagejpeg($targetLayer,$folderPath. $fileNewName. "_thump.". $ext);
                            break;
            
            
                        default:
                            echo "Invalid Image type.";
                            exit;
                            break;
                    }
            
            
                    move_uploaded_file($file, $folderPath. $fileNewName. ".". $ext);
                    echo "Image Resize Successfully.";
                }
            }
            
            
            function imageResize($imageResourceId,$width,$height) {
            
            
                $targetWidth =200;
                $targetHeight =200;
            
            
                $targetLayer=imagecreatetruecolor($targetWidth,$targetHeight);
                imagecopyresampled($targetLayer,$imageResourceId,0,0,0,0,$targetWidth,$targetHeight, $width,$height);
            
            
                return $targetLayer;
            }
            ?>
            

            【讨论】:

            • 嗨,欢迎来到 stackoverflow!请对此代码进行任何解释?
            【解决方案10】:

            我按照https://www.w3schools.com/php/php_file_upload.asphttp://www.w3bees.com/2013/03/resize-image-while-upload-using-php.html 的步骤生成了这个解决方案:

            在我看来(我使用的是 MVC 范例,但它可能是您的 .html.php 文件,或者您用于前端的技术):

            <form action="../../photos/upload.php" method="post" enctype="multipart/form-data">
            <label for="quantity">Width:</label>
              <input type="number" id="picture_width" name="picture_width" min="10" max="800" step="1" value="500">
            Select image to upload:
            <input type="file" name="fileToUpload" id="fileToUpload">
            <input type="submit" value="Upload Image" name="submit">
            </form>
            

            我的upload.php

            <?php
            /* Get original image x y*/
            list($w, $h) = getimagesize($_FILES['fileToUpload']['tmp_name']);
            $new_height=$h*$_POST['picture_width']/$w;
            /* calculate new image size with ratio */
            $ratio = max($_POST['picture_width']/$w, $new_height/$h);
            $h = ceil($new_height / $ratio);
            $x = ($w - $_POST['picture_width'] / $ratio) / 2;
            $w = ceil($_POST['picture_width'] / $ratio);
            /* new file name */
            //$path = 'uploads/'.$_POST['picture_width'].'x'.$new_height.'_'.basename($_FILES['fileToUpload']['name']);
            $path = 'uploads/'.basename($_FILES['fileToUpload']['name']);
            /* read binary data from image file */
            $imgString = file_get_contents($_FILES['fileToUpload']['tmp_name']);
            /* create image from string */
            $image = imagecreatefromstring($imgString);
            $tmp = imagecreatetruecolor($_POST['picture_width'], $new_height);
            imagecopyresampled($tmp, $image,
                0, 0,
                $x, 0,
                $_POST['picture_width'], $new_height,
                $w, $h);
            $uploadOk = 1;
            $imageFileType = strtolower(pathinfo($path,PATHINFO_EXTENSION));
            // Check if image file is a actual image or fake image
            if(isset($_POST["submit"])) {
                $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
                if($check !== false) {
                    //echo "File is an image - " . $check["mime"] . ".";
                    $uploadOk = 1;
                } else {
                    //echo "File is not an image.";
                    $uploadOk = 0;
                }
            }
            // Check if file already exists
            if (file_exists($path)) {
                echo "Sorry, file already exists.";
                $uploadOk = 0;
            }
            // Check file size
            if ($_FILES["fileToUpload"]["size"] > 500000) {
                echo "Sorry, your file is too large.";
                $uploadOk = 0;
            }
            // Allow certain file formats
            if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
            && $imageFileType != "gif" ) {
                echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";
                $uploadOk = 0;
            }
            // Check if $uploadOk is set to 0 by an error
            if ($uploadOk == 0) {
                echo "Sorry, your file was not uploaded.";
                // if everything is ok, try to upload file
            } else {
                /* Save image */
                switch ($_FILES['fileToUpload']['type']) {
                    case 'image/jpeg':
                        imagejpeg($tmp, $path, 100);
                        break;
                    case 'image/png':
                        imagepng($tmp, $path, 0);
                        break;
                    case 'image/gif':
                        imagegif($tmp, $path);
                        break;
                    default:
                        exit;
                        break;
                }
                echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.";
                /* cleanup memory */
                imagedestroy($image);
                imagedestroy($tmp);
            }
            ?>
            

            存储图片的文件夹的名称称为“uploads/”。您需要先创建该文件夹,然后才能看到您的图片。它对我很有用。

            注意:这是我的表格:

            代码正在正确上传和调整图片大小。我使用此链接作为指南:http://www.w3bees.com/2013/03/resize-image-while-upload-using-php.html。我对其进行了修改,因为在该代码中它们指定了调整大小图片的宽度和高度。就我而言,我只想指定宽度。我自动按比例计算的高度,只是保持适当的图片比例。一切都很完美。我希望这会有所帮助。

            【讨论】:

              【解决方案11】:

              Zebra_Image 库的完整示例,我认为它非常简单实用。代码很多,但是如果你看的话,cmet也很多,所以你可以复制粘贴快速使用。

              此示例验证图像格式、大小并用自定义分辨率替换图像大小。 There is Zebra library 和文档(仅下载 Zebra_Image.php 文件)。

              解释

              1. 图片通过uploadFile函数上传到服务器。
              2. 如果图片上传正确,我们通过getUserFile函数恢复该图片及其路径。
              3. 将图像大小调整为自定义宽度和高度并替换为相同的路径。

              主要功能

              private function uploadImage() {        
                  $target_file = "../img/blog/";
                  
              //this function could be in the same PHP file or class. I use a Helper (see bellow)
                  if(UsersUtils::uploadFile($target_file, $this->selectedBlog->getId())) {
              //This function is at same Helper class.
              //The image will be returned allways if there isn't errors uploading it, for this reason there aren't validations here.
                      $blogPhotoPath = UsersUtils::getUserFile($target_file, $this->selectedBlog->getId());
                      
                      // create a new instance of the class
                      $imageHelper = new Zebra_Image();
                      // indicate a source image
                      $imageHelper->source_path = $blogPhotoPath;
                      // indicate a target image
                      $imageHelper->target_path = $blogPhotoPath;
                      // since in this example we're going to have a jpeg file, let's set the output
                      // image's quality
                      $imageHelper->jpeg_quality = 100;
              
                      // some additional properties that can be set
                      // read about them in the documentation
                      $imageHelper->preserve_aspect_ratio = true;
                      $imageHelper->enlarge_smaller_images = true;
                      $imageHelper->preserve_time = true;
                      $imageHelper->handle_exif_orientation_tag = true;
                      // resize
                      // and if there is an error, show the error message
                      if (!$imageHelper->resize(450, 310, ZEBRA_IMAGE_CROP_CENTER)) {
                          // if there was an error, let's see what the error is about
                          switch ($imageHelper->error) {
                              case 1:
                                  echo 'Source file could not be found!';
                                  break;
                              case 2:
                                  echo 'Source file is not readable!';
                                  break;
                              case 3:
                                  echo 'Could not write target file!';
                                  break;
                              case 4:
                                  echo 'Unsupported source file format!';
                                  break;
                              case 5:
                                  echo 'Unsupported target file format!';
                                  break;
                              case 6:
                                  echo 'GD library version does not support target file format!';
                                  break;
                              case 7:
                                  echo 'GD library is not installed!';
                                  break;
                              case 8:
                                  echo '"chmod" command is disabled via configuration!';
                                  break;
                              case 9:
                                  echo '"exif_read_data" function is not available';
                                  break;
                          }
                      } else {
                          echo 'Image uploaded with new size without erros');
                      }
                  }
              }
              

              外部函数或在同一个 PHP 文件中使用删除 public static 限定符。

                  public static function uploadFile($targetDir, $fileName) {        
                  // File upload path
                  $fileUploaded = $_FILES["input-file"];
                  
                  $fileType = pathinfo(basename($fileUploaded["name"]),PATHINFO_EXTENSION);
                  $targetFilePath = $targetDir . $fileName .'.'.$fileType;
                  
                  if(empty($fileName)){
                      echo 'Error: any file found inside this path';
                      return false;
                  }
                  
                  // Allow certain file formats
                  $allowTypes = array('jpg','png','jpeg','gif','pdf');
                  if(in_array($fileType, $allowTypes)){
                      //Max buffer length 8M
                      var_dump(ob_get_length());
                      if(ob_get_length() > 8388608) {
                          echo 'Error: Max size available 8MB';
                          return false;
                      }
                      // Upload file to server
                      if(move_uploaded_file($fileUploaded["tmp_name"], $targetFilePath)){
                          return true;
                      }else{
                          echo 'Error: error_uploading_image.';
                      }
                  }else{
                      echo 'Error: Only files JPG, JPEG, PNG, GIF y PDF types are allowed';
                  }
                  return false;
              }
              
              public static function getUserFile($targetDir, $userId) {
                  $userImages = glob($targetDir.$userId.'.*');
                  return !empty($userImages) ? $userImages[0] : null;
              }
              

              【讨论】:

                【解决方案12】:

                下载库文件 Zebra_Image.php 链接

                https://drive.google.com/file/d/0Bx-7K3oajNTRV1I2UzYySGZFd3M/view

                resizeimage.php

                <?php
                    require 'Zebra_Image.php';
                    // create a new instance of the class
                     $resize_image = new Zebra_Image();
                     // indicate a source image
                    $resize_image->source_path = $target_file1;
                    $ext = $photo;
                    // indicate a target image
                    $resize_image->target_path = 'images/thumbnil/' . $ext;
                    // resize
                    // and if there is an error, show the error message
                    if (!$resize_image->resize(200, 200, ZEBRA_IMAGE_NOT_BOXED, -1));
                    // from this moment on, work on the resized image
                    $resize_image->source_path = 'images/thumbnil/' . $ext;
                ?>
                

                【讨论】:

                • 这条评论不完整...有一些变量没有初始化,比如$photo或者$target_file1;
                猜你喜欢
                • 2014-03-14
                • 1970-01-01
                • 2011-01-10
                • 1970-01-01
                • 2012-09-27
                • 2011-04-16
                • 2013-12-07
                • 2015-12-05
                相关资源
                最近更新 更多