Coder Social home page Coder Social logo

php-ext-zopfli's Introduction

Zopfli Extension for PHP

Build Status

This extension allows Zopfli compression.

Documentation for Zopfli can be found at » https://github.com/google/zopfli.

Build

% git submodule update --init
% phpize
% ./configure
% make
$ make install

Configration

php.ini:

extension=zopfli.so

Function

  • zopfli_encode — Create a gzip compressed string
  • zopfli_compress — Compress a string
  • zopfli_deflate — Deflate a string
  • zopfli_decode — Decodes a gzip compressed string
  • zopfli_uncompress — Uncompress a compressed string
  • zopfli_inflate — Inflate a deflated string
  • zopfli_png_recompress — Recompress IDAT chunks in a PNG Image

zopfli_encode — Create a gzip compressed string

Description

string zopfli_encode ( string $data [, int $iteration = 15 [, int $encoding = ZOPFLI_GZIP ]] )

This function returns a compressed version of the input data compatible with the output of the gzip program.

Parameters

  • data

    The data to encode.

  • iteration

    The iteration of compression. Specify a value greater than 0.

  • encoding

    The encoding mode. Can be ZOPFLI_GZIP (the default) or ZOPFLI_DEFLATE, ZOPFLI_ZLIB.

Return Values

The encoded string, or FALSE if an error occurred.

zopfli_compress — Compress a string

Description

string zopfli_compress ( string $data [, int $iteration = 15 ] )

This function compress the given string using the ZLIB data format.

Parameters

  • data

    The data to compress.

  • iteration

    The iteration of compression. Specify a value greater than 0.

Return Values

The compressed string or FALSE if an error occurred.

zopfli_deflate — Deflate a string

Description

string zopfli_deflate ( string $data [, int $iteration = 15 ] )

This function compress the given string using the DEFLATE data format.

Parameters

  • data

    The data to deflate.

  • iteration

    The iteration of compression. Specify a value greater than 0.

Return Values

The deflated string or FALSE if an error occurred.

zopfli_decode — Decodes a gzip compressed string

Description

string zopfli_decode ( string $data [, int $length = 0 ] )

This function returns a decoded version of the input data.

same as gzdecode().

Pameters

  • data

    The data to decode, encoded by zopfli_encode(), gzencode().

  • length

    The maximum length of data to decode.

Return Values

The decoded string, or FALSE if an error occurred.

zopfli_uncompress — Uncompress a compressed string

Description

string zopfli_uncompress ( string $data [, int $length = 0 ] )

This function uncompress a compressed string.

same as gzuncompress().

Parameters

  • data

    The data compressed by zopfli_compress(), gzcompress().

  • length

    The maximum length of data to decode.

Return Values

The original uncompressed data or FALSE on error.

zopfli_inflate — Inflate a deflated string

Description

string zopfli_inflate ( string $data [, int $length = 0 ] )

This function inflate a deflated string.

same as gzinflate().

Parameters

  • data

    The data compressed by zopfli_deflate(), gzdeflate().

  • length

    The maximum length of data to decode.

Return Values

The original uncompressed data or FALSE on error.

zopfli_png_recompress — Recommress IDAT chunks in PNG Image

Description

string zopfli_png_recompress ( string $data [, int $iteration = 15 ] )

This function recompresses IDAT chunks in a PNG Image.

Parameters

  • data

    The PNG Image

  • iteration

    The iteration of compression. Specify a value greater than 0.

Return Values

The recompressed PNG Image or FALSE on error.

Examples

$data = zopfli_encode('test');

zopfli_decode($data);
//gzdecode($data);

$data = zopfli_compress('test');

zopfli_uncompress($data);
//gzuncompress($data);

$data = zopfli_deflate('test');

zopfli_inflate($data);
//gzinflate($data);

$data = file_get_contents('original.png');
$recompress = zopfli_png_recompress($data);
file_put_contents('recompress.png', $recompress);

Related

php-ext-zopfli's People

Contributors

kjdev avatar peterdavehello avatar jbboehr avatar cubicdaiya avatar dktapps avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.