elfeffe/php-image-optim 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

elfeffe/php-image-optim

Composer 安装命令:

composer require elfeffe/php-image-optim

包简介

A library to aid in image optimisation

README 文档

README

This is a fork of bensquire library, where I plan to add some other tools.

The purpose of this library is to help automate the optimisation of images via the command line in PHP,

Installation:

The library is PSR-0 compliant and the simplest way to install it is via composer, simply add:

{
    "require": {
        "elfeffe/php-image-optim": "dev-master"
    }
}

into your composer.json, then run 'composer install' or 'composer update' as required.

Example:

This example demonstrates the optimisation of a PNG file, by chaining several commands together.

<?php
    use PHPImageOptim\PHPImageOptim,
        PHPImageOptim\Tools\Png\OptiPng,
        PHPImageOptim\Tools\Png\PngCrush,
        PHPImageOptim\Tools\Png\PngQuant;

    include('../../vendor/autoload.php');

    $advPng = new AdvPng();
    $advPng->setBinaryPath('/usr/local/bin/advpng');

    $optiPng = new OptiPng();
    $optiPng->setBinaryPath('/usr/local/bin/optipng');

    $pngOut = new PngOut();
    $pngOut->setBinaryPath('/usr/bin/pngout');

    $pngCrush = new PngCrush();
    $pngCrush->setBinaryPath('/usr/local/bin/pngcrush');

    $pngQuant = new PngQuant();
    $pngQuant->setBinaryPath('/usr/local/bin/pngquant');

    $optim = new PHPImageOptim();
    $optim->setImage('/tmp/lenna.png');
    $optim  ->chainCommand($pngQuant)
            ->chainCommand($advPng)
            ->chainCommand($optiPng)
            ->chainCommand($pngCrush)
            ->chainCommand($pngOut);
    $optim->optimise();

统计信息

  • 总下载量: 10
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 19
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-09-03