Softaculous


Topic : Php getimagesize and Swf


Posted By: vmulot on March 17, 2014, 2:39 pm
Hi
first of all, thanks for Ampps, it's a really nice soft :)
I'm encountering a little pb with the php function "getimagesize". i can't read the size (width and height) of a SWf file.

i got this error message :

Quote
Notice (8): getimagesize(): The image is a compressed SWF file, but you do not have a static version of the zlib extension enabled ....


any idea on how to solve that ?
i tried with php 5.3 and 5.4

Posted By: vmulot on March 17, 2014, 2:45 pm | Post: 1
Sorry i forgot that :
Mac OS Mavericks
Ampps 4.4.4

Posted By: tidus on March 19, 2014, 9:41 am | Post: 2
Hi,

Sorry we have never tried using getimagesize on .swf so we won't be able to help you much. You can report this issue to PHP Bug or GD Team as its related to PHP Extension. Before reporting a bug there, have a look at this post.

PHP Code

<?php

/*

    ----------------------------------------------------------------------

    PHP Blob Data As File Stream v1.0 (C) 2012 Alex Yam <alexyam@live.com>

    This code is released under the MIT License.

    ----------------------------------------------------------------------

    [Summary]



    A simple class for PHP functions to read and write blob data as a file

    using a stream wrapper.



    Particularly useful for running getimagesize() to get the width and

    height of .SWF Flash files that are stored in the database as blob data.



    Tested on PHP 5.3.10.



    ----------------------------------------------------------------------    

    [Usage Example]



    //Include

        include('./blob_data_as_file_stream.php');



    //Register the stream wrapper

        stream_wrapper_register("BlobDataAsFileStream", "blob_data_as_file_stream");



    //Fetch a .SWF file from the Adobe website and store it into a variable.

    //Replace this with your own fetch-swf-blob-data-from-database code.

        $swf_url = '[url=http://www.adobe.com/swf/software/flash/about/flashAbout_info_small.swf]http://www.adobe.com/swf/software/flash/about/flashAbout_info_small.swf[/url]';

        $swf_blob_data = file_get_contents($swf_url);

    

    //Store $swf_blob_data to the data stream

        blob_data_as_file_stream::$blob_data_stream = $swf_blob_data;

    

    //Run getimagesize() on the data stream

        $swf_info = getimagesize('BlobDataAsFileStream://');

        var_dump($swf_info);



    ----------------------------------------------------------------------

    [Usage Output]



    array(5) {

      [0]=>

      int(159)

      [1]=>

      int(91)

      [2]=>

      int(13)

      [3]=>

      string(23) "width="159" height="91""

      ["mime"]=>

      string(29) "application/x-shockwave-flash"

    }



*/



class blob_data_as_file_stream {



    private static 
$blob_data_position 0;

    public static 
$blob_data_stream '';



    public static function 
stream_open($path,$mode,$options,&$opened_path){

        static::
$blob_data_position 0;

        return 
true;

    }



    public static function 
stream_seek($seek_offset,$seek_whence){

        
$blob_data_length strlen(static::$blob_data_stream);

        switch (
$seek_whence) {

            case 
SEEK_SET:

                
$new_blob_data_position $seek_offset;

                break;

            case 
SEEK_CUR:

                
$new_blob_data_position = static::$blob_data_position+$seek_offset;

                break;

            case 
SEEK_END:

                
$new_blob_data_position $blob_data_length+$seek_offset;

                break;

            default:

                return 
false;

        }

        if ((
$new_blob_data_position >= 0) AND ($new_blob_data_position <= $blob_data_length)){

            static::
$blob_data_position $new_blob_data_position;

            return 
true;

        }else{

            return 
false;

        }

    }



    public static function 
stream_tell(){

        return static::
$blob_data_position;

    }



    public static function 
stream_read($read_buffer_size){

        
$read_data substr(static::$blob_data_stream,static::$blob_data_position,$read_buffer_size);

        static::
$blob_data_position += strlen($read_data);

        return 
$read_data;

    }



    public static function 
stream_write($write_data){

        
$write_data_length=strlen($write_data);

        static::
$blob_data_stream substr(static::$blob_data_stream,0,static::$blob_data_position).

            
$write_data.substr(static::$blob_data_stream,static::$blob_data_position+=$write_data_length);

        return 
$write_data_length;

    }



    public static function 
stream_eof(){

        return static::
$blob_data_position >= strlen(static::$blob_data_stream);

    }



}

?>




-----------------------
Follow AMPPS on,
Twitter : https://twitter.com/AMPPS_Stack
Facebook :  http://www.facebook.com/softaculousampps
Google+ : https://plus.google.com/+AmppsStack

Powered By AEF 1.0.8 © 2007-2008 Electron Inc.