Download the PHP package rosell-dk/webp-on-demand without Composer

On this page you can find all versions of the php package rosell-dk/webp-on-demand. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package webp-on-demand

WebP on demand

This library is now part of WebP Convert and thus obsolete!

This is a solution for automatically serving WebP images instead of jpeg/pngs for browsers that supports WebP (Google Chrome, that is).

Once set up, it will automatically convert images, no matter how they are referenced. It for example also works on images referenced in CSS. As the solution does not require any change in the HTML, it can easily be integrated into any website / framework (A Wordpress adaptation was recently published on wordpress.org - its also on github)

NOTE: This library will be part of WebP Convert soon (depreciated, that is)

Overview

A setup consists of these parts:

Requirements

Installation

The first two steps are whether you are going to use composer or not. Not using composer? - Follow me!

1. Require this library with composer

composer require rosell-dk/webp-on-demand

2. Create the script

Create a file webp-on-demand.php, and place it in webroot, or where-ever you like in you web-application.

Here is a minimal example to get started with:

3. Add redirect rules

Place the following rewrite rules in a .htaccess file in the directory you want webp-on-demand to do its magic:

If you have placed webp-on-demand.php in a subfolder, you will need to change the rewrite rule accordingly.

4. Validate that it works

Browse to an JPEG image. Instead of an image, you should see a conversion report. Hopefully, you get a success. Otherwise, you need to hook up to a cloud converter or try to meet the requirements for cwebp, gd or imagick. You can learn more about available options at the github page for webp-convert

Once you get a successful conversion, you can uncomment the "show-report" option in the script.

It should work now, but to be absolute sure:

  1. Visit a page on your site with an image on it, using Google Chrome.
    • Right-click the page and choose "Inspect"
    • Click the "Network" tab
    • Reload the page
    • Find a jpeg or png image in the list. In the "type" column, it should say "webp". There should also be a X-WebP-On-Demand header on the image.

5. Customizing and tweaking

Basic customizing is done by setting options in the $options array:

Other tweaking is described in docs/tweaks.md:

Troubleshooting

The redirect rule doesn't seem to be working

If images are neither routed to the converter or a 404, it means that the redirect rule isn't taking effect. Common reasons for this includes:

Related


All versions of webp-on-demand with dependencies

PHP Build Version
Package Version
Requires rosell-dk/webp-convert Version ^1.1.0
rosell-dk/webp-convert-and-serve Version ^0.4.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package rosell-dk/webp-on-demand contains the following files

Loading the files please wait ....