2013-07-05 63 views
0

當我和個人圖像文件運行getimagesize()使用此代碼PHP和getimagesize()函數返回1,1(寬度,高度)

$list = getimagesize("http://img.bleacherreport.net/img/images/photos/002/386/662/hi-res-159212879_crop_north.jpg?w=650&h=440&q=75"); 
echo '<pre>'; 
print_r($list); 

返回

Array 
(
    [0] => 650 
    [1] => 440 
    [2] => 2 
    [3] => width="650" height="440" 
    [bits] => 8 
    [channels] => 3 
    [mime] => image/jpeg 
) 

但是當我運行getimagesize()在迴路中

foreach ((array) $image_list as $imagepath) 
{ 
$list = getimagesize($imagepath); 
echo '<br/>'.$list[0].'-'.$list[1]; 
} 

它返回1 - 1。這是我的問題。 如果我打印$list陣列

Array 
(
    [0] => 1 
    [1] => 1 
    [2] => 1 
    [3] => width="1" height="1" 
    [bits] => 1 
    [channels] => 3 
    [mime] => image/gif 
) 

數組列表爲foreach循環

Array 
(
    [0] => http://b.scorecardresearch.com/p?c1=2&c2=6246855&c4=bleacherreport.com/articles/1694365-nba-free-agents-2013-players-who-will-make-big-impact-on-new-teams&cv=2.0&cj=1 
    [1] => http://pixel.quantserve.com/pixel/p-3a-0o8sJKz6Ek.gif 
    [2] => http://static2.bleacherreport.net/images/redesign/common/loading/small.gif?1372800971 
    [3] => http://static.bleacherreport.net/images/redesign/modules/uber-module/teamstream_header.png 
    [4] => http://cdn.bleacherreport.net/images/team_logos/24x24/nba.png 
    [5] => http://static.bleacherreport.net/images/redesign/common/icon_comment.png 
    [6] => http://img.bleacherreport.net/img/images/photos/002/386/662/hi-res-159212879_crop_north.jpg?w=650&h=440&q=75 
    [7] => http://img.bleacherreport.net/img/article/media_slots/photos/000/953/247/hi-res-158291245_crop_exact.jpg?w=650&h=432&q=85 
    [8] => http://img.bleacherreport.net/img/article/media_slots/photos/000/953/261/hi-res-7261336_crop_exact.jpg?w=650&h=434&q=85 
    [9] => http://img.bleacherreport.net/img/article/media_slots/photos/000/953/256/hi-res-171671545_crop_exact.jpg?w=340&h=227&q=85 
    [10] => http://img.bleacherreport.net/img/article/media_slots/photos/000/953/253/hi-res-167372126_crop_exact.jpg?w=650&h=434&q=85 
    [11] => http://static2.bleacherreport.net/images/redesign/common/loading/small.gif?1372800971 
    [12] => http://img.bleacherreport.net/img/images/photos/002/383/560/hi-res-6914404_crop_650_crop_north.jpg?w=200&h=126&q=75 
    [13] => http://img.bleacherreport.net/img/images/photos/002/383/690/ScreenShot2013-07-02at3.21.16PM_crop_north.png?w=200&h=126&q=75 
    [14] => http://img.bleacherreport.net/img/images/photos/002/380/987/Screenshot2013-07-01at10.08.02AM_crop_north.jpg?w=200&h=126&q=75 
    [15] => http://static.bleacherreport.net/images/redesign/avatars/default-user-icon-comment.png 
    [17] => http://static2.bleacherreport.net/images/redesign/common/loading/small.gif?1372800971 
    [18] => http://static.bleacherreport.net/images/articles/no-comments.png 
    [19] => http://static.bleacherreport.net/images/shared/spinners/big.gif 
    [20] => http://static.bleacherreport.net/images/redesign/articles/vote.png 
    [21] => http://static.bleacherreport.net/images/redesign/articles/reply.png 
    [22] => http://static2.bleacherreport.net/images/redesign/common/loading/small.gif?1372800971 
    [23] => http://static2.bleacherreport.net/images/redesign/common/loading/small.gif?1372800971 
    [24] => http://img.bleacherreport.net/img/images/photos/002/380/803/ScreenShot2013-06-30at10.54.05PM_crop_north.jpg?w=100&h=68&q=75 
    [25] => http://img.bleacherreport.net/img/images/photos/002/386/676/hi-res-157492860_crop_north.jpg?w=100&h=68&q=75 
    [26] => http://img.bleacherreport.net/img/images/photos/002/386/826/hi-res-167733787_crop_north.jpg?w=100&h=68&q=75 
    [27] => http://img.bleacherreport.net/img/images/photos/002/386/396/ScreenShot2013-07-04at5.12.55PMcopy_original_crop_north.jpg?w=100&h=68&q=75 
    [28] => http://img.bleacherreport.net/img/images/photos/002/386/670/hi-res-6960530_crop_north.jpg?w=100&h=68&q=75 
    [29] => http://img.bleacherreport.net/img/images/photos/002/386/690/ScreenShot2013-07-05at9.42.36AM_original_crop_north.jpg?w=100&h=68&q=75 
    [30] => http://img.bleacherreport.net/img/images/photos/002/265/104/ScreenShot2013-04-17at3.07.21PM_crop_north.png?w=340&h=234&q=75 
    [31] => http://img.bleacherreport.net/img/images/photos/002/320/773/hi-res-72281689_crop_north.jpg?w=100&h=68&q=75 
    [32] => http://img.bleacherreport.net/img/images/photos/001/909/267/ScreenShot2012-09-27at10.14.17AM_crop_north.png?w=100&h=68&q=75 
    [33] => http://static2.bleacherreport.net/images/articles/icon-fb.png?1372800977 
    [34] => http://static2.bleacherreport.net/images/redesign/facebook/connect.png?1372800977 
    [35] => http://cdn.bleacherreport.net/images/team_logos/50x50/nba.png 
    [36] => http://static2.bleacherreport.net/images/redesign/common/loading/small.gif?1372800977 
    [38] => http://analytics.bleacherreport.com/b/ss/sidbleacherreport/1/H.25.2--NS/0 
) 
+0

循環中的路徑是否與首先測試的路徑相同? – Barmar

+0

你能爲我們'var_dump($ imagepath)'嗎? – n1te

+0

@ n1te我在我的問題中添加了數組列表。 – Kabir

回答

1

之所以一些圖片返回1 - 1是因爲圖像只1x1它返回這個數組。我只是自己運行代碼並下載了一些返回1 - 1的圖像,它們是1px乘1px。

例如這個是1x1:http://pixel.quantserve.com/pixel/p-3a-0o8sJKz6Ek.gif

+0

但是當我運行URL'http://img.bleacherreport.net/img/images/photos/002/386/662/hi-res-159212879_crop_north.jpg?w = 650&h = 440&q = 75'個別使用'getimagesize ()'那麼它工作完美。 – Kabir

+0

@Kabir當我將上面的url添加到我的數組(其中有5個其他url已經在其中)時,我得到了'650-440'這是正確的 – n1te

相關問題