hdrjpg / hdrjpg-sdk-php
The official PHP SDK to convert high dynamic range photos into web-ready HDR files using the hdrjpg.com API.
Requires
- php: >=7.4
- ext-json: *
- ext-zip: *
- guzzlehttp/guzzle: ^6.5.8 || ^7.4.5
README
The official PHP SDK to convert high dynamic range photos into web-ready HDR files using the hdrjpg.com API.
Install
composer require hdrjpg/hdrjpg-sdk-php
Usage
Each conversion allows for the creation of a custom combination of image sizes, qualities and formats. The supported source HDR image formats are HEIC and EXR. Supported HDR output formats are JPEG-XT, JPEG-XL, AVIF and MP4. All files retain HDR information after the conversion. See hdrjpg.com for more information on compatibility and conversion options.
use TinCat\HdrjpgSdkPhp\Client; $client = new Client('iS1nrfLP7KSCkeVlb1hKUL39eyUHsjE+KnLwmh6j'); // Replace with your API Key $client->convert( 'example.heic', // Complete path for your Source HDR image file [ // An array of variants [ // Each variant defines the settings for each resulting image 'width' => 1200, 'baseQuality' => 98, 'format' => 'jpeg-xt' ], [ 'width' => 800, 'baseQuality' => 98, 'format' => 'jpeg-xt' ], [ 'width' => 300, 'baseQuality' => 98, 'gainmapQuality' => 95, 'format' => 'jpeg-xt' ], [ 'width' => 1200, 'baseQuality' => 98, 'format' => 'jpeg-xl' ], [ 'height' => 300, 'baseQuality' => 98, 'fileName' => 'image-converted', 'format' => 'avif' ], [ 'height' => 300, 'baseQuality' => 98, 'format' => 'mp4' ] ], '/tmp' // Output directory to save resulting files to );
This method will wait for the conversion to be completed, and can take up to a few minutes depending on the size of the source image and the variants and formats requested.
Advanced usage
Conversion is internally a three steps process that can be leveraged individually to better suit your implementation workflow. If you need finer control over this process, see the file examples/advanced-convert.php for an example on how to perform the conversion steps separately.
Free testing API Key
Visit hdrjpg.com/documentation/testing-api-key to get a free testing API Key.
Requirements
- PHP 7.4 or higher