项目作者: szepeviktor

项目描述 :
Advanced real-time image optimization with mozjpeg on your server - WordPress plugin
高级语言: PHP
项目地址: git://github.com/szepeviktor/image-factory.git
创建时间: 2015-11-13T21:51:51Z
项目社区:https://github.com/szepeviktor/image-factory

开源协议:

下载


Image Factory

Advanced real-time image optimization with mozjpeg on your server.

This project uses JPEG Archive by Daniel G. Taylor
which depends on mozjpeg, an improved JPEG encoder.

Install dependencies and background worker

  1. apt-key adv --keyserver pgp.mit.edu --recv-keys 451A4FBA
  2. echo "deb http://szepeviktor.github.io/debian/ jessie main" > /etc/apt/sources.list.d/szepeviktor.list
  3. apt-get update && apt-get install -y socat optipng jpeginfo jpeg-archive
  4. cp -a ./bin/image-factory-worker.sh /usr/local/bin/

Install init script and options

Source: https://github.com/asaif/socat-init

Replace www-data (in 3 places) with the PHP user.

  1. cp -a ./init.d/socat /etc/init.d/
  2. cat > /etc/default/socat.conf <<<EOF
  3. SOCAT_DEFAULTS="-d -d -d -ly"
  4. OPTIONS="UNIX-LISTEN:/var/www/above-document-root/factory.sock,mode=600,fork,user=www-data,group=www-data EXEC:/usr/local/bin/image-factory-worker.sh,pipes,su=www-data"
  5. EOF
  6. update-rc.d socat defaults

Optional second instance.

  1. cp -a ./init.d/socat /etc/init.d/socat02
  2. sed -i 's;/etc/default/socat\.conf;/etc/default/socat02.conf;' /etc/init.d/socat02
  3. cat > /etc/default/socat02.conf <<<EOF
  4. SOCAT_DEFAULTS="-d -d -d -ly"
  5. OPTIONS="UNIX-LISTEN:/var/www/other-document-root/factory.sock,mode=600,fork,user=www-data,group=www-data EXEC:/usr/local/bin/image-factory-worker.sh,pipes,su=www-data"
  6. EOF
  7. update-rc.d socat02 defaults

Setting Socket path

The Socket path option is on the Settings / Media page.

Or you could add a define to your wp-config.php:

  1. define( 'IMAGE_FACTORY_SOCKET', '/var/www/site/factory.sock' );

Manual test

  1. wp option add "image_factory_socket" "/var/www/above-document-root/factory.sock" --autoload=no
  2. /usr/bin/socat UNIX-LISTEN:/var/www/above-document-root/factory.sock,mode=600,fork,user=www-data,group=www-data EXEC:/usr/local/bin/image-factory-worker.sh,pipes,su=www-data

Now upload a JPEG image to Media Library and watch syslog:

tail -f /var/log/syslog

TODO

Support systemd.