- $list = $xpath->query("//img[@src]");
- foreach ($list as $node) {
- $attr = array();
- if ($node->attributes->length)
- foreach ($node->attributes as $attribute)
- $attr[$attribute->name] = $attribute->value;
-
- // guess mimetype from headers or filename
- $type = guess_image_type($attr["src"],true);
-
- $i = fetch_url($attr["src"]);
- $ph = new Photo($i, $type);
-
- if($ph->is_valid() and ($ph->getWidth() > 200) and ($ph->getHeight() > 200)) {
- if ($siteinfo["image"] == "")
- $siteinfo["image"] = $attr["src"];
-
- if($ph->getWidth() > 300 || $ph->getHeight() > 300) {
- $ph->scaleImage(300);
- $siteinfo["images"][] = array("src"=>$attr["src"],
- "width"=>$ph->getWidth(),
- "height"=>$ph->getHeight());
- } else
- $siteinfo["images"][] = array("src"=>$attr["src"],
- "width"=>$ph->getWidth(),
- "height"=>$ph->getHeight());
+ $list = $xpath->query("//img[@src]");
+ foreach ($list as $node) {
+ $attr = array();
+ if ($node->attributes->length)
+ foreach ($node->attributes as $attribute)
+ $attr[$attribute->name] = $attribute->value;
+
+ $src = completeurl($attr["src"], $url);
+ $photodata = @getimagesize($src);
+
+ if (($photodata) && ($photodata[0] > 150) and ($photodata[1] > 150)) {
+ if ($photodata[0] > 300) {
+ $photodata[1] = round($photodata[1] * (300 / $photodata[0]));
+ $photodata[0] = 300;
+ }
+ if ($photodata[1] > 300) {
+ $photodata[0] = round($photodata[0] * (300 / $photodata[1]));
+ $photodata[1] = 300;
+ }
+ $siteinfo["images"][] = array("src"=>$src,
+ "width"=>$photodata[0],
+ "height"=>$photodata[1]);