Download the PHP package codebuds/webp-converter without Composer

On this page you can find all versions of the php package codebuds/webp-converter. 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-converter

Webp Converter

I had already found a great webP conversion package rosell-dk/webp-convert that seems to work in many cases.

However, most of my projects will now be running on PHP7.4 and Symfony5, so I created a very small converter for those situations.

Usage

You can use composer to get this package :

composer require codebuds/webp-converter

Then, inside a Symfony controller for example you can use it like the following :

The WebPConverter::createWebpImage static function needs the resource for the image.

This can either just be the path to the image, in which case the function itself will try to create the Symfony\Component\HttpFoundation\File\File from the path.

You can also directly pass the File element if you want :

Exceptions

Multiple exceptions can be thrown. First the Symfony File is used for the guessExtension() function. This allows us to check the type of file provided and will make sure whether the file is called .JPG, .jpeg, .jpg, ... or something else, but it ends up being a jpeg file this is what will be used. If the file is not one of the allowed types (jpeg, png, gif and bmp) an exception will be thrown.

If the provided image is already a webP image the exception will send that information.

If the saveFile or the force options are not booleans, or the quality option is not an integer between 1 and 100 the information will be in an exception.

The filename, filenameSuffix and savePath options need to be strings.

If saveFile is set to true and force to the default false value, and the webP image already exists an exception will be thrown to let the user know force needs to be set to true is you want to override an existing file.

Finally, if the file is one of the allowed types but something goes wrong during the conversion made by GD that exception will be forwarded.

Return values

If no exceptions are present the return will consist of the webP image ressource and what the path would be for the image if you want it saved in the same directory as the original one.

Options

You can also set options but this is not required.

The saveFile option is false by default. As mentioned before this will only return the ressource, and the possible path for the webP image. This means you then need to run the gd function to save the image.

However, if you set this function to true the image will be saved automatically by triggering the gd imagewebp function.

If you want to save the file directly there are more options to customize the webP file and it's location :

This example will create the webP image /var/www/symfony/public/webp/a_new_file_q50.webp

Default values :

As that is possible, the second option is quality which by default is 80. This is only useful if the saveFile option is set to true (as the image is not created and saved otherwise).


All versions of webp-converter with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
ext-gd Version *
symfony/http-foundation Version ^7.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 codebuds/webp-converter contains the following files

Loading the files please wait ....