2011-11-30 70 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); 
相关问题