douqiu1604 2013-11-09 22:36
浏览 33

使用php获取图像全尺寸

i would like to save image in original size from a given url.

For example, i have the following site: *

I am possible to get all the images from this url but the size is very small. All the images have an img tag with source looking like /fileadmin/media/images/cat_thumb/xxx.jpg

But the img tag is inside an a href link which is showing the image in fullsize. And i need this img, not the small one

Note that this size is only an example, and i am looking for some generic solutin to find images in original/thumbnail size.

Here is a code snippet i am using to save the small images...

$html = file_get_html($url); foreach($html->find('img') as $element) { echo url_to_absolute($url, $element->src), "</br>"; }

  • 写回答

1条回答 默认 最新

  • doudouxuqh198138 2013-11-09 22:52
    关注

    Your post is confusing so my answer could be off.

    Something like this should set you on the right path (not tested)

    $html = file_get_html($url); 
    foreach($html->find('img')->parent('a') as $element) 
    { 
     $page_url = url_to_absolute($url, $element->href); 
     $page_html = file_get_html($page_url); 
    }
    

    But the only true way you can check an image width/height is by copying it to your server first and using getimagesize() to get height and width.

    评论

报告相同问题?

悬赏问题

  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号