2011-11-30 74 views

回答

1

這將遍歷圖像並比較寬度,高度...如果它大於設置的有效尺寸,那麼它會將其插入到數組$ validImgs中。

$validImgs = array(); 
$validWidth = 60; 
$validHeight = 70; 

foreach($images as $imageChoices){ 
    list($width, $height) = getimagesize($imageChoices); 
    if($width >= $validWidth && $height >= $validHeight){ 
    $validImgs[] = $imageChoices; 
    } 
} 
+0

謝謝,效果很好! –

0

這裏的粗樣機如何可以做到這一點:

$image_60 = array(); 
$image_70 = array(); 

foreach($images as $imageChoices) { 
    $data = getimagesize($imageChoices); 
    if ($data[0] > 60) $image_60[] = $imageChoices; 
    if ($data[0] > 70) $image_70[] = $imageChoices; 
} 

請注意,我創建兩個數組$image_60$image_70,一個與寬度> 60,一個用於與寬度>圖片圖片70.那裏做什麼取決於你想要用這些圖像進行存檔。

1

試試這個。

$theSize = array(); 
foreach($images as $imageChoices) { 
    list($width, $height, $type, $attr) = getimagesize($imageChoices); 
    if($width > 60 && $height > 70) $theSize[] = getimagesize($imageChoices); 
} 
//array contents only images ,(width > 60 and height > 70) 
print_r($theSize); 
相關問題