PHP:
<?php
// make sure there is NO output before this script, no blankspace, no nothing
// or you'll get a "headers already sent" error
// the image from another site
$off_site = 'http://news.google.com/images/news.gif';
// read binary stream
$fp = fopen ($off_site, 'rb') or die('Unable to open file '.$off_site.' for reading');
while (!feof ($fp))
{
$buf .= fgets($fp, 4096);
}
// output header
header('Content-Type: image/jpeg');
$data = $buf;
//set new height
$size = 20;
$src = imagecreatefromstring ($data);
$width = imagesx($src);
$height = imagesy($src);
$aspect_ratio = $height/$width;
//start resizing
if ($height <= $size) {
$new_w = $width;
$new_h = $height;
} else {
$new_h = $size;
$new_w = abs($new_h / $aspect_ratio);
}
$img = imagecreatetruecolor ($new_w,$new_h);
//output image
imagecopyresampled ($img,$src,0,0,0,0,$new_w,$new_h,$width,$height);
// determine image type and send it to the browser
imagejpeg($img, '', 90);
imagedestroy($img);
?>
Would like to seek for advice.
The script is working for
$off_site = 'http://news.google.com/images/news.gif';
But if I set the $off_site = 'http://211.25.186.7/snap.jpg'
It doesn't work.
Any idea?
Thanks in advance!!!





