Php contains the zlib Link Library, which can be used directly. The following is an example of my compressed and compressed swf files:
// If the swf file is not compressed, the first byte of the file is 'f' or 'C '.
Compress the swf file:
// Configure //--------------------------------------------------------------------------------------------------
// File name
$ Filename = "test.swf ";
// Open the file
$ Rs = fopen ($ filename, "r ");
// Read the file data
$ Str = fread ($ rs, filesize ($ filename ));
// Set the swf header file
$ Head = substr ($ str, 1, 8 );
$ Head = "C". $ head;
// Obtain the swf File Content
$ Body = substr ($ str, 8 );
// Compress the file content with a maximum compression level of 9
$ Body = gzcompress ($ body, 9 );
// Merge the file header and content
$ Str = $ head. $ body;
// Close the Read File stream
Fclose ($ rs );
// Create a new file
$ Ws = fopen ("create.swf", "w ");
// Write an object
Fwrite ($ ws, $ str );
// Close file retention
Fclose ($ ws );
// Configure //----------------------------------------------------------------------------------------------------
?>
Decompress the swf file:
// Configure //----------------------------------------------------------------------------------------------------
// File name
$ Filename = "test.swf ";
// Open the file
$ Rs = fopen ($ filename, "r ");
// Read the file data
$ Str = fread ($ rs, filesize ($ filename ));
// Set the swf header file
$ Head = substr ($ str, 1, 8 );
$ Head = "F". $ head;
// Obtain the swf File Content
$ Body = substr ($ str, 8 );
// Decompress the File Content
$ Body = gzuncompress ($ body );
// Merge the file header and content
$ Str = $ head. $ body;
// Close the Read File stream
Fclose ($ rs );
// Create a new file
$ Ws = fopen ("create.swf", "w ");
// Write an object
Fwrite ($ ws, $ str );
// Close file retention
Fclose ($ ws );
// Configure //----------------------------------------------------------------------------------------------------
?>
How is it? Is it easy? Haha, php not only gives us simple "'