Download the PHP package shykat199/webpbolt without Composer

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

WebpBolt — Fast, Modular Image to WebP Converter for PHP

Convert JPG, PNG, GIF and BMP images to WebP in PHP — one file at a time, or an entire directory tree in a single call. Lightweight, zero dependencies, built on PHP's native GD extension.

WebP files are typically 25–35% smaller than JPG and PNG, so converting your images makes websites load faster and improves Core Web Vitals.

Features

Requirements

Check WebP support:

Installation

Quick start

Convert one image

WebpBolt is a thin fluent wrapper. The underlying ImageProcessor API is unchanged and still available if you prefer it:

Convert a whole folder

That's the common case. Everything below is for when you need more control.


Batch conversion

Preview before you commit

On a production folder, always dry-run first. It walks the tree and counts everything without writing a single file:

Watch the progress

Pass a callback to get told about each file as it's handled. Add countFirst() if you want a real total in the output — it costs one extra pass over the folder:

Resize everything while converting

Pass a pre-configured ImageProcessor and its transforms apply to every file in the batch:

Convert in place

Leave the destination unset and each .webp is written next to its original:

Handle failures

The batch never stops on a bad file. Errors are collected and handed back:

Run it from cron

Repeat runs are cheap — the skip check reads file timestamps and never decodes an image, so an already-converted tree of 40,000 files finishes in seconds:

All batch options

Method Default What it does
source(string $dir) required Folder to read from
destination(?string $dir) null Where to write. null writes beside each original
recursive(bool) true Include subfolders
skipExisting(bool) true Skip files already converted and up to date
keepSmaller(bool) true Discard output that came out bigger than the source
dryRun(bool) false Count and measure, write nothing
countFirst(bool) false Pre-count the tree so progress shows a total
maxPixels(int) ~64M Refuse images above this pixel count. 0 disables
onProgress(callable) — fn($file, $done, $total, $status)

Turn skipExisting off to force a full rebuild — for example after changing the quality setting:

Reading the result

run() returns a BatchResult:


Single-image pipeline

Chain transforms, then encode

Resize fits the image inside the given box while keeping its aspect ratio, and only ever shrinks — passing a box larger than the image leaves it untouched.

Note that transforms stay attached to the processor, so reusing an instance applies them again to the next file. That's exactly what you want when feeding it to BatchProcessor; create a fresh ImageProcessor when you don't.

Watermarking

Stamp text or a logo onto an image. Two named constructors, then chain only the things you want to change — every option has a working default.

That's a complete watermark: white text, bottom-right, 60% opacity, 20px margin.

Text watermarks

Without font() this falls back to GD's built-in bitmap font, which needs no asset files but is small and blocky. For anything customer-facing, pass a real .ttf.

color() takes '#ffffff', 'fff', 'ffffff' or [255, 255, 255].

Image watermarks

Use a PNG with a transparent background. scale() is a fraction of the base image width, not a pixel size — 0.2 means the logo is 20% as wide as the photo. That keeps it proportionate whether you're stamping a thumbnail or a 4000px original; a fixed pixel width would be enormous on one and invisible on the other.

Positions

position() accepts the Position enum or its string value:

Enum String
Position::TopLeft 'top-left'
Position::TopCenter 'top-center'
Position::TopRight 'top-right'
Position::MiddleLeft 'middle-left'
Position::Center 'center'
Position::MiddleRight 'middle-right'
Position::BottomLeft 'bottom-left'
Position::BottomCenter 'bottom-center'
Position::BottomRight 'bottom-right' (default)

The enum gives you IDE autocompletion and turns a typo into an error instead of a mis-placed logo. Strings are there for config-driven setups.

All watermark options

Method Default Applies to What it does
position($p) BottomRight both Where it sits
opacity(int) 60 both 0 invisible, 100 solid
margin(int) 20 both Gap from the edge, in pixels
scale(float) 0.18 image Width as a fraction of the base image
font(string, int) — text Path to a .ttf, plus point size
color(string\|array) white text Hex string or RGB array

Order matters

Add the watermark after the resize:

Watermarking first means the logo gets shrunk along with the photo and comes out tiny and blurry. Transforms run in the order you add them, and nothing enforces this for you.

Watermarking a whole folder

Pass a configured processor to BatchProcessor and every file gets the same treatment:

Architecture

Add a new transform

One file in src/Transforms/ implementing TransformInterface:

Then use it: ->addTransform(new Watermark('© Me')). No other file changes.

A transform may return a different GdImage than it was given — Resize does, because it has to build a new canvas. Treat the handle you passed in as invalid once apply() has returned.

Add a new output format

One file in src/Encoders/ implementing EncoderInterface:

It then works everywhere an encoder is accepted, batch included:

Quality guide

Quality Use case
90–100 Photography, minimal loss
75–85 Websites (recommended default)
50–70 Thumbnails, maximum compression

Notes and limitations

License

MIT

Laravel

The package auto-registers when installed in a Laravel app. Publish the config:

Set your defaults once in config/webpbolt.php:

Then convert a folder from the command line:

An ImageProcessor pre-configured from that config is bound in the container, so injecting it anywhere gives you the resize and watermark for free:

Put it on a schedule to catch new uploads. Repeat runs cost one filesystem stat per file, so this is cheap:

Errors

Everything thrown extends WebpBoltException, which extends RuntimeException — so existing catch (RuntimeException) blocks keep working while new code can catch precisely:

BatchProcessor catches these per file and collects them in $result->failed, so one bad image never stops a run.

Testing


All versions of webpbolt with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
ext-gd Version *
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 shykat199/webpbolt contains the following files

Loading the files please wait ...