marc wrote:
this by the way 'http://poietic-aggregator.com/ap/Furtherfield' is beautiful...

thanks,

your blogs list is a great source for materials, so now this one:

http://yann.x-arn.org/getfeed/4.php

generates a juxtaposition with 4 pictures found in blogs from the list

sometimes funny, sometimes a bit slow (everything in 'real time' accross the net)... in progress...

the raw script below , for PHP addicts :)

++


<pre>
<?php

//extrait la liste de blogs et la met dans un tableau
$url_tab = array();
if ($a = @fopen("http://www.furtherfield.org/displaylinks.php?link_set=11","r";)) {
    while( $line = fgets($a, 1024) ) {
        if ( preg_match("`gotowork\('(.*)'\)`", $line, $t) ) {
            $url_tab[] = $t[1];
        }
    }
    fclose($a);
    print_r($url_tab);

} else {
    echo "global failure";
    exit;
}

//tableau des url d'images sources
$imsrc = array();

function getImg($url, $limit) {
    global $imsrc;
$pattern='/<(input|img)[^>]*src=([\\"\\\']?)(http[^> ]*\.(jpg|jpeg))([\\"\\\']?) [^>]*>/i';
    if( $f = @fopen($url, 'r') ) {
        $n=0;
        while( $line = fgets($f, 1024) ) {
             if(preg_match($pattern, $line, $images) && $n < $limit) {
                print_r($images[3]);
                echo "\n";
                $n++;
                $imsrc[] = $images[3];

             }
        }
        fclose($f);
        if( $n == $limit) {
            echo "success\n\n";
            return true;
        } else {
            echo "failure (no jpg)\n\n";
            return false;
        }
    } else {
        echo "failure (can't open URL)\n\n";
        return false;
    }
}



//nombre d'urls de blogs

$nb = count($url_tab);

function chooseUrl() {
    global $url_tab, $nb;
    $u = rand(0,$nb);//determine 1 url au pif dans la liste
    $url = $url_tab[$u];
    echo "checking: $url\n";
    if( !getImg($url,1) ) {//Et va chercher la premiere image
        chooseUrl();
    } else {
        return true;
    }
}


for($i=0; $i<4; $i++) {
    //echo "\n<!-- loop: $i -->\n";
    chooseUrl();
}

print_r($imsrc);



$im = imagecreatetruecolor (640, 480);
for($j=0; $j<count($imsrc); $j++) {
    if($info = @getimagesize($imsrc[$j])) {
        $im_w = $info[0];
        $im_h = $info[1];
        $ims = imagecreatefromjpeg($imsrc[$j]);
        $imtemp = imagecreatetruecolor (320, 240);
        imagecopyresampled ($imtemp, $ims, 0, 0, 0, 0, 320, 240, $im_w, $im_h);
        if($j==0) {
            $x=0;
            $y=0;
        } else if($j==1) {
            $x=320;
            $y=0;
        } else if($j==2) {
            $x=0;
            $y=240;
        } else if($j==3) {
            $x=320;
            $y=240;
        }
        imagecopy($im, $imtemp, $x, $y, 0, 0, 320, 240);
        imagedestroy($imtemp);
        imagedestroy($ims);
    } else {
        echo "failure : can't open ".$imsrc[$j]."\n";
    }
}
imagejpeg($im, 'test.jpg');
imagedestroy($im);


?>
<img src="test.jpg">

</pre>


--






_______________________________________________
NetBehaviour mailing list
[email protected]
http://www.netbehaviour.org/mailman/listinfo/netbehaviour

Reply via email to