2013-03-30 20 views
0

這個腳本一些如何顯示圖像而不是整個圖像的一半...我想這出這裏有什麼問題大小調整圖像 - 只顯示一半如果PIC

任何幫助,請

//文件

     $ftimage = $_POST['feature_image']; 

         // maximum height 150 X width 150 
         $width = 150; 
         $height = 150; 


         // Dimensions Set 
         list($width_orig, $height_orig) = getimagesize($ftimage); 

         $ratio_orig = $width_orig/$height_orig; 

         if ($width/$height > $ratio_orig) { 
          $width = $height*$ratio_orig; 
         } else { 
          $height = $width/$ratio_orig; 
         } 

         // Resample 
         $image_p = imagecreatetruecolor($width, $height); 
         $image = imagecreatefromjpeg($ftimage); 
         imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig); 

         // Output 
         $image = imagejpeg($image_p, null, 100); 
         var_dump($image); 
+0

你嘗試用不同的圖像?同樣的結果給大家? – Uby

+0

輸出'$ width_orig'和'$ height_orig',看看是否正確。 – bitWorking

回答

-1

試圖取代它

$ftimage = $_POST['feature_image']; 

吧:

$ftimage = $_POST['feature_image']['tmp_name']; 

或者,如果你的POST請求遠程存儲圖像的URL,嘗試類似的東西:

$image = imagecreatefromstring(file_get_contents($ftimage)); 
+0

我認爲這裏沒有文件上傳 – 2013-03-30 09:01:33