Code Monkey home page Code Monkey logo

ewwwio-php's Introduction

EWWW Image Optimizer - PHP library

License: GPLv3

This is a PHP library that you can use to integrate with the EWWW Image Optimizer Compress API. The Compress API can be used to reduce image filesize using lossless and lossy methods as well as image format conversion.

By default, EWWW Image Optimizer uses lossy JPG and lossless PNG optimization techniques, The lossy optimization for JPG and PNG files uses sophisticated algorithms to minimize perceptual quality loss, which is vastly different than setting a static quality/compression level.

WebP Images

Can generate WebP versions of your images (will not remove originals, since you'll need both versions to support all browsers), and enables you to serve even smaller images to supported browsers.

Usage

No Composer support yet, the library bundles it's own copy of Requests by rmccue and friends, and is known to be compatible with version 2.0.8.

Include the library, and start rolling:

include_once( 'ewwwio-php/ewwwio.php' );
$ewwwio = new EWWWIO( 'abc123' ); // API key is required at instantiation.
$result = $ewwwio->optimize( '/var/www/images/sample.jpg' );
if ( ! $result ) { // find out what the problem was...
    echo $ewwwio->get_error() . "\n";
}

You can also verify your key like so:

if ( $ewwwio->verify_key() ) {
        echo "huzzah\n";
} else {
        echo "booo\n";
}

Options are set as properties/attributes, and you can inspect the available API options in ewwwio.php:

$ewwwio->debug = true; // enables logging to debug.log
$ewwwio->jpg_level = 30; // Maximum compression, 20 = regular lossy, and 10 = lossless
$ewwwio->webp = true; // Generates a .webp image alongside the optimized image if WebP is smaller.
$ewwwio->webp_force = true; // Always keep the generated WebP, even if it is a little bigger.

Changelog

1.2

  • update to Requests 2.0.9

1.1

  • added: SVG optimization
  • updated to Requests 2.x
  • updated code formatting
  • fixed cloud_optimizer() return value handling for PDF files
  • fixed temp files being left behind when key is invalid

1.0

  • fixed conversion bugs, fully tested and marking stable

0.90

  • initial release, may eat your cat

ewwwio-php's People

Contributors

fvdm avatar nosilver4u avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  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.