PHPackages                             joppuyo/jpeg-xl-encode - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Image &amp; Media](/categories/media)
4. /
5. joppuyo/jpeg-xl-encode

ActiveLibrary[Image &amp; Media](/categories/media)

joppuyo/jpeg-xl-encode
======================

A PHP library for encoding JPEG XL images. Very much inspired by WebP Convert.

v1.2.0(2y ago)19361[13 issues](https://github.com/joppuyo/jpeg-xl-encode/issues)[2 PRs](https://github.com/joppuyo/jpeg-xl-encode/pulls)MITPHPPHP &gt;=7.2.5

Since Aug 30Pushed 1y ago1 watchersCompare

[ Source](https://github.com/joppuyo/jpeg-xl-encode)[ Packagist](https://packagist.org/packages/joppuyo/jpeg-xl-encode)[ GitHub Sponsors](https://github.com/joppuyo)[ RSS](/packages/joppuyo-jpeg-xl-encode/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (9)Dependencies (7)Versions (14)Used By (0)

JPEG XL Encode
==============

[](#jpeg-xl-encode)

[![GitHub Workflow Status](https://camo.githubusercontent.com/469e107ddddfbce3f9f674b4be68bfdd4f0ab41b5a2c9a87a7f8ffe39a9dc0e8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6a6f707075796f2f6a7065672d786c2d656e636f64652f746573742e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473266c6f676f3d676974687562)](https://github.com/joppuyo/jpeg-xl-encode/actions)[![Packagist Version](https://camo.githubusercontent.com/abc196c8630b2192c351da8f16d2431f0d6972599402309959aba8d88071c66a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a6f707075796f2f6a7065672d786c2d656e636f6465)](https://packagist.org/packages/joppuyo/jpeg-xl-encode)[![codecov](https://camo.githubusercontent.com/c3230036809e2bdf34313324909a51a8ed8469ae877c39cca0f70d3d064cc968/68747470733a2f2f636f6465636f762e696f2f67682f6a6f707075796f2f6a7065672d786c2d656e636f64652f6272616e63682f6d61696e2f67726170682f62616467652e7376673f746f6b656e3d4b42544b53524e454736)](https://codecov.io/gh/joppuyo/jpeg-xl-encode)[![Packagist PHP Version Support](https://camo.githubusercontent.com/7d3509f52257f250571036dad67643b59477dcf155fa2b2162b356e37c369443/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6a6f707075796f2f6a7065672d786c2d656e636f6465)](https://packagist.org/packages/joppuyo/jpeg-xl-encode)[![Packagist License](https://camo.githubusercontent.com/d116360cbef65534d8863652d002d9510fe5dc39897e2c70476fe3072a688b1e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6a6f707075796f2f6a7065672d786c2d656e636f6465)](https://packagist.org/packages/joppuyo/jpeg-xl-encode)[![REUSE status](https://camo.githubusercontent.com/1070832ff38c212de2ebedaf52b44725f3e3d292be6046f20ce11ba78840de07/68747470733a2f2f6170692e72657573652e736f6674776172652f62616467652f6769746875622e636f6d2f6a6f707075796f2f6a7065672d786c2d656e636f6465)](https://api.reuse.software/info/github.com/joppuyo/jpeg-xl-encode)[![Active Development](https://camo.githubusercontent.com/05bf2133d87fedc2fd15e0028eebeede53bc1be03be2e50371ef8c8bee6c2344/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4d61696e74656e616e63652532304c6576656c2d4163746976656c79253230446576656c6f7065642d627269676874677265656e2e737667)](https://gist.github.com/cheerfulstoic/d107229326a01ff0f333a1d3476e068d)

A PHP library for encoding JPEG XL images. Supports JPEG and PNG input. Very much inspired by the excellent [WebP Convert](https://github.com/rosell-dk/webp-convert) library.

It is intended as a plug-and-play solution that covers the most common use cases and it can be used in a wide variety of PHP projects.

Requirements
------------

[](#requirements)

- PHP 7.2.5 or later.
- Linux, macOS or Windows OS
- One or more of the following methods of encoding JPEG XL images needs to be available:
    - The `proc_open` PHP function needs to be enabled so the library can execute the cjxl binary on the command line.
    - The `vips` PHP extension is installed and enabled. VIPS image processing library must be compiled with jxl support
    - The `imagick` PHP extension is installed and enabled. ImageMagick library needs to be compiled with jxl support

Installation
------------

[](#installation)

```
composer require joppuyo/jpeg-xl-encode

```

Usage
-----

[](#usage)

```
require __DIR__ . '/vendor/autoload.php';

$source = '/absolute/path/to/source.jpeg';
$destination = '/absolute/path/to/destination.jxl';
$options = [
    'encoding' => 'lossy',
    'quality' => 80,
];
try {
    \NPX\JpegXlEncode\Encoder::encode($source, $destination, $options);
} catch (Exception $exception) {
    error_log('Whoops, something went wrong.');
}
```

Options
-------

[](#options)

### Encoding

[](#encoding)

`encoding`

Selects which encoding to use, `lossy` for VarDCT and `lossless` for Modular. Default is `lossy` for JPEG input and `lossless` for PNG input.

### Quality

[](#quality)

`quality`

Image quality for lossy compression. The quality range goes from `1` to `100`. Default is `85`.

### Effort

[](#effort)

`effort`

Controls how much time is used for image encoding. Longer encoding time means smaller files. Range is from `1` to `9` where `1` is the fastest and `9` is the slowest. Default is `7`.

### Progressive

[](#progressive)

`progressive`

Enables progressive decoding for the image. If a web browser supports progressive rendering, the image will download perceptually faster. In VarDCT mode, progressive decoding does not affect the file size much.

Enabling progressive decoding for Modular images is not recommended since it makes the resulting image file significantly larger. It could be enabled at a later date in a future version when there are browsers that support downloading only part of a modular progressive file.

Default value is `true` for lossy and `false` for lossless.

Methods
-------

[](#methods)

There are four different methods you can use: cjxl binary, cjxl system binary, ImageMagick extension and Vips extension. The library goes through each of the available methods and tries to use them. If none of the methods are available, an exception will be thrown.

### Cjxl binary

[](#cjxl-binary)

This method executes the `cjxl` binary on the command line. It's the most compatible method and it supports the most features. However, the `proc_open` function needs to be enabled in the PHP installation since the library executes the binary on the command line. Some web hosts may disable this function for security reasons.

Note: this library comes bundled with statically compiled version of the `cjxl` binary for Linux, macOS and Windows systems. The binary is bundled with all the required libraries which means it will work out of the box without the need to install any additional dependencies.

### Cjxl system binary

[](#cjxl-system-binary)

This is the same as the previous method but it executes the `cjxl` binary from system PATH. This means you need to install jpeg xl using your system package manager like homebrew or build jpeg xl from source and add the `cjxl` binary to your PATH variable.

### ImageMagick extension

[](#imagemagick-extension)

This method uses the ImageMagick library and its PHP extension Imagick. However, ImageMagick needs to be built with JXL delegate. In practice, this means you will need to install the libjxl library on the server. Then you will need to build ImageMagick from the source with the option `--with-jxl=yes`. Lastly, you will need to install the Imagick PHP extension. The ImageMagick extension does not support progressive encoding at the time. For an example how to compile ImageMagick with JPEG XL support, see [this Dockerfile](https://github.com/joppuyo/jpeg-xl-encode/blob/main/imagemagick.Dockerfile).

### Vips extension

[](#vips-extension)

This method uses the vips library and its PHP extension. However, vips needs to be built with JXL support. In practice, this means you will need to install the libjxl library on the server. Then you will need to build vips from the source. Lastly, you will need to install the vips PHP extension. The vips extension does not support progressive encoding at the time. For an example how to compile VIPS with JPEG XL support, see [this Dockerfile](https://github.com/joppuyo/jpeg-xl-encode/blob/main/vips.Dockerfile).

In addition the vips extension, you will also need to install the `jcupitt/vips` PHP library in your project in addition `jpeg-xl-encode`, you can do this by using the following command:

```
composer require jcupitt/vips

```

License
-------

[](#license)

MIT.

For detailed license information, see the individual file headers and [`.reuse/dep5`](.reuse/dep5).

Maintance level
---------------

[](#maintance-level)

This project is under active development and it has a number of features currently under development.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance14

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 99.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~81 days

Recently: every ~160 days

Total

9

Last Release

1063d ago

Major Versions

v0.2.1 → v1.0.02022-08-06

### Community

Maintainers

![](https://www.gravatar.com/avatar/f3c4b44161119b358d2b0a29605a3e0ebff3ee26a170cb642b095730e8f9d746?d=identicon)[joppuyo](/maintainers/joppuyo)

---

Top Contributors

[![joppuyo](https://avatars.githubusercontent.com/u/1595438?v=4)](https://github.com/joppuyo "joppuyo (177 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")

---

Tags

imageimage-processingimagesjpeg-xljpegxljxlphpphp-libraryphp7convertimageconverterencodeimagesencoderjpeg xljpegxljxl

###  Code Quality

TestsCodeception

### Embed Badge

![Health badge](/badges/joppuyo-jpeg-xl-encode/health.svg)

```
[![Health](https://phpackages.com/badges/joppuyo-jpeg-xl-encode/health.svg)](https://phpackages.com/packages/joppuyo-jpeg-xl-encode)
```

###  Alternatives

[spatie/image

Manipulate images with an expressive API

1.4k54.4M138](/packages/spatie-image)[h4cc/wkhtmltoimage-amd64

Convert html to image using webkit (qtwebkit). Static linked linux binary for amd64 systems.

20110.7M15](/packages/h4cc-wkhtmltoimage-amd64)[orbitale/imagemagick-php

A system that allows creating commands to send to the exec() function to use ImageMagick's powerful features.

43385.7k1](/packages/orbitale-imagemagick-php)[jbzoo/image

A PHP class that simplifies working with images

171126.9k3](/packages/jbzoo-image)[h4cc/wkhtmltoimage-i386

Convert html to image using webkit (qtwebkit). Static linked linux binary for i386 systems.

33656.3k5](/packages/h4cc-wkhtmltoimage-i386)[andrewgjohnson/imagettftextblur

imagettftextblur is a drop in replacement for imagettftext with added parameters to add blur, glow and shadow effects to your PHP GD images

27198.4k1](/packages/andrewgjohnson-imagettftextblur)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
