Giter Site home page Giter Site logo

modxwebpconverter's Introduction

modxWebpConverter

modxWebpConverter, user manual - Webp converter for MODX Revo

ReadMe на русском

MODX Revolution is a plugin that converts image files to webp format.

Install & use

  1. Create a subdirectory /connectors/converter/ and fill the files there:
  • converter.php - Server api
  • converter.js - Script for admin panel
  • Binaries - Binary utilities cwebp, there is for linux, windows, macos, freebsd, solaris.

The binaries are taken from https://github.com/rosell-dk/webp-convert and https://developers.google.com/speed/webp/docs/precompiled

Install & Update bin files cwebp tool

  1. Creating a plugin in the admin panel: modx_plugin_webp_converter.php and hang it on the events:
  • OnManagerPageBeforeRender
  • OnWebPagePrerender
  • OnSiteRefresh
  • OnTemplateSave
  • OnChunkSave
  • OnPluginSave
  • OnSnippetSave
  • OnTemplateVarSave
  • OnDocFormSave

After that, an icon will appear in the upper-right menu. When you click on it, the site directories will be scanned in the background, and a copy of each image in the webp subdirectory will be created. i.e. /assets/logo.png - > /webp/assets/logo.png.webp

  1. After converting all found images, all images in the site's HTML code will be replaced with webp, if the browser supports them.

The results of testing

Tested on MODX Revolution 2.7.3-pl!

  • Windows 7 64bit XAMPP PHP 7.4.9,
  • linux Ubuntu 20.04 64bit LAMP PHP 7.4.3,
  • linux CentOS 7 LANMP PHP 5.4.45

Took a selection of jpg & png, 24382 files, 3385MB.

Everything worked fine, memory consumption is at a peak: on win 6 580 936b, on lin 3 816 368b. Scanning subdirectories took: 191ms SSD, 3123ms HDD. Compression of a single file takes from 28ms to 5800ms. The resulting volume of compressed files: 1005MB, no loss in quality was noticed.

I opened 12 tabs in the browser at the same time, as a result, the encoding went to 12 threads, I have a Ryzen 5 2600X Six-Core processing of all files took about 45 minutes.

modxwebpconverter's People

Contributors

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