PHP code example of izica / php-progressive-images-webp-jp2-jxr
1. Go to this page and download the library: Download izica/php-progressive-images-webp-jp2-jxr library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
izica / php-progressive-images-webp-jp2-jxr example snippets
$obData = \Izica\ProgressiveImages::fromFileSource('/upload/iblock/fe7/fe7728c5f2c6763693eb1d9ef105c46c.png')
->setFileName('custom-file-name')
->setDestinationFolder($_SERVER['DOCUMENT_ROOT'] . '/test/cache/')
->convert();
/*
Izica\ProgressiveImagesResponse Object
(
[source] => /upload/iblock/fe7/fe7728c5f2c6763693eb1d9ef105c46c.png
[webp] => /test/cache/custom-file-name.webp
[jpeg2000] => /test/cache/custom-file-name.jp2
[jpegxr] => /test/cache/custom-file-name.jxr
)
*/
$arData = \Izica\ProgressiveImages::fromFileSource('/upload/iblock/fe7/fe7728c5f2c6763693eb1d9ef105c46c.png')
->setFileName('custom-file-name')
->setDestinationFolder($_SERVER['DOCUMENT_ROOT'] . '/test/cache/')
->convert()
->toArray();
/*
Array
(
[source] => /upload/iblock/fe7/fe7728c5f2c6763693eb1d9ef105c46c.png
[webp] => /test/cache/custom-file-name.webp
[jpeg2000] => /test/cache/custom-file-name.jp2
[jpegxr] => /test/cache/custom-file-name.jxr
)
*/
$arData = \Izica\ProgressiveImages::fromFileSource('/upload/iblock/fe7/fe7728c5f2c6763693eb1d9ef105c46c.png')
->setFileName('custom-file-name')
->setDestinationFolder($_SERVER['DOCUMENT_ROOT'] . '/test/cache/')
->withoutJpegXr()
->withoutJpeg2000()
->convert();
/*
Izica\ProgressiveImagesResponse Object
(
[source] => /upload/iblock/fe7/fe7728c5f2c6763693eb1d9ef105c46c.png
[webp] => /test/cache/custom-file-name.webp
[jpeg2000] =>
[jpegxr] =>
)
*/