|  | 
  Ben Coakley - 2008-07-03 19:23:51Is it possible to create an animated GIF using GIFs from another web server?  I'm trying to animate weather radar data from a series of still frames.  Essentially, I've taken your example.php script, and replaced the loop which creates the $frames and $framed arrays with the following lines:
 $frames [ ] = "http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r.cgi?&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&FORMAT=image/gif&TRANSPARENT=true&WIDTH=600&HEIGHT=400&SRS=EPSG:4326&BBOX=-92,37,-72,51&STYLES=default&LAYERS=nexrad-n0r";
 $framed [ ] = 500;
 $frames [ ] = "http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r.cgi?&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&FORMAT=image/gif&TRANSPARENT=true&WIDTH=600&HEIGHT=400&SRS=EPSG:4326&BBOX=-92,37,-72,51&STYLES=default&LAYERS=nexrad-n0r-m05min";
 $framed [ ] = 500;
 
 When I use this script, I get the error:
 
 Warning: filesize() [function.filesize]: stat failed for http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r.cgi?&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&FORMAT=image/gif&TRANSPARENT=true&WIDTH=600&HEIGHT=400&SRS=EPSG:4326&BBOX=-92,37,-72,51&STYLES=default&LAYERS=nexrad-n0r in C:\apache\htdocs\nexrad\GIFEncoder.class.php on line 65
 
 Warning: fread() [function.fread]: Length parameter must be greater than 0 in C:\apache\htdocs\nexrad\GIFEncoder.class.php on line 65
 GIFEncoder V2.05: 0 Source is not a GIF image!
 
 Which makes it look like it's trying to read the file from the local filesystem, and not from the web.  Am I misunderstanding the 'url' source type?  Those URLs are for a public WMS server, which returns GIF files of current weather data.
 
 (My testing server is Windows / Apache 2.2 / PHP 5.1, but this ultimately needs to run under Linux / Apache 2 / PHP 5.)
 
 Thanks,
 --Ben
  László Zsidi - 2008-09-24 21:00:12 - In reply to message 1 from Ben CoakleyUse the "url" flag instead of "bin" flag and add the absolute path into the frame array, e.g.:
 $frame[] = "http://www.anotherserver.com/frame.gif";
 
 $gif_pointer = new GIFEncoder ( ... "url" );
  László Zsidi - 2008-09-24 21:34:52 - In reply to message 1 from Ben CoakleyOhhhhh....seems to be it does not work also with the "url" flag...I am thinking on the solution...
  Joseph - 2009-03-07 13:03:20 - In reply to message 3 from László ZsidiDid you find a solution? I also need to use your class with external images.
  László Zsidi - 2009-03-07 14:44:40 - In reply to message 4 from JosephHi,
 You should use the fsockopen ( ) function to read external image sources.
 
 Example:
 
 <?
 $host='site.com';
 $port=3000;
 $path='/home/login/public_html/pic.php';
 
 // the file you want to upload
 $file_array[0] = "../pic.jpg"; // the file
 $content_type = "image/jpeg"; // the file mime type
 
 srand((double)microtime()*1000000);
 $boundary = "---------------------------".substr(md5(rand(0,32000)),0,10);
 
 $data = "--$boundary";
 
 for($i=0;$i<count($file_array);$i++) {
 $content_file = join("", file($file_array[$i]));
 $data.="
 Content-Disposition: form-data; name=\"file".($i+1)."\"; filename=\"$file_array[$i]\"
 Content-Type: $content_type
 
 $content_file
 --$boundary";
 }
 
 $data.="--\r\n\r\n";
 
 $msg =
 "POST $path HTTP/1.0
 Content-Type: multipart/form-data; boundary=$boundary
 Content-Length: ".strlen($data)."\r\n\r\n";
 
 $result="";
 
 // open the connection
 $f = fsockopen($host, $port);
 fputs($f,$msg.$data);
 
 // get the response
 while (!feof($f)) $result .= fread($f,32000);
 
 fclose($f);
 
 ?>
 |