|
brian taylor - 2009-02-09 04:16:11
I'm having the same problem that another user had (Ben) and interestingly enough I am also working on a weather related project.
I'm getting this message:
arning: filesize() [function.filesize]: stat failed for (ext server - anim.gif) in /file.php on line 56
Warning: fread() [function.fread]: Length parameter must be greater than 0 in /file.php on line 56
The file that I'm trying to read is an animated gif with 13 frames. It's updated on another web server hourly. I need to download this file into my webserver (of course to the /frames folder).
Did you have any luck fixing Ben's problem? I think mine might be the same.
Thanks,
Brian
brian taylor - 2009-02-09 04:25:29 - In reply to message 1 from brian taylor
I thought I would be more clear (just in case).,
I have no problems with the encode script - once the single gif files are located in the /frames directory. My problem is pulling an animated gif from another webserver, chopping it up frame by frame and storing them into the /frames dir.
The default decodeder script isn't working - here is what I have:
$file = "http://www.example.com/animated.gif";
$fp = fread (fopen($file,"rb"), filesize($file));
require "GIFDecoder.class.php";
if ( $fp ) {
$gif = new GIFDecoder ( $fp );
$arr = $gif->GIFGetFrames ( );
$dly = $gif->GIFGetDelays ( );
for ( $i = 0; $i < count ( $arr ); $i++ ) {
fwrite ( fopen ( ( $i < 10 ? "frames/0$i_frame.gif" : "frames/$i_frame.gif" ), "wb" ), $arr [ $i ] );
}
for ( $i = 0; $i < count ( $dly ); $i++ ) {
sprintf ( "Delay of %d frame is %d ms<br>", $i, ( $dly [ $i ] * 10 /* milliseconds */ ) );
}
}
It outputs the errors that I detailed in previous (original) post.
Thanks,
Brian
László Zsidi - 2009-02-09 04:39:47 - In reply to message 2 from brian taylor
Hi,
My idea that you try to use fsockopen ( ) /Open Internet or Unix domain socket connection/ instead of fopen ( ) /Local file open/.
You can find more references about fsockopen at http://php.net/manual/en/function.fsockopen.php
A simple example from php.net:
<?php
$fp = fsockopen("www.example.com", 80, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {
$out = "GET / HTTP/1.1\r\n";
$out .= "Host: www.example.com\r\n";
$out .= "Connection: Close\r\n\r\n";
fwrite($fp, $out);
while (!feof($fp)) {
echo fgets($fp, 128);
}
fclose($fp);
}
?>
Have a nice day!
Laci
brian taylor - 2009-02-09 06:05:07 - In reply to message 3 from László Zsidi
I'm not sure that I'm understanding if or not I am properly using your code. Even when I put a copy of the anim.gif on my server and use your decode class - I get the same results as if I use "file_get_contents" to pull it from a remote server.
It creates 2 images in the /frames directory:
.gif
0.gif
There are suppose to be 13 frames, but it starts to copy the second frame and "breaks" without giving it a name...
does this sound familiar to you, or have you ran across this issue before?
Thanks,
Brian
László Zsidi - 2009-02-09 15:39:31 - In reply to message 4 from brian taylor
Hm, it's very interesting...
Please put an animation file into your server and send me the full path and i try to decode on my server by my decoder class, i would like to test.
|