简体   繁体   中英

php getimagesize() function returning the 1, 1 (Width, Height)

When I run getimagesize() with individual image files with this code

$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);

it returns

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

But when I run getimagesize() in a loop

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

it returns 1 - 1 . This is my problem. it is returning this array if i print the $list array

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

Array List for foreach loop

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
)

The reason why some of the images return 1 - 1 is because the images are simply 1x1 . I just ran the code myself and downloaded the some of the images which returned 1 - 1 and they were 1px by 1px.

eg this one is 1x1: http://pixel.quantserve.com/pixel/p-3a-0o8sJKz6Ek.gif

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM