1. Go to this page and download the library: Download splitbrain/slika 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/ */
splitbrain / slika example snippets
use \splitbrain\slika\Slika;
use \splitbrain\slika\Exception;
$options = [
'quality' => 75
];
try {
Slika::run('input.png', $options)
->resize(500,500)
->rotate(Slika::ROTATE_CCW
->save('output.jpg', 'jpg');
} catch (Exception $e) {
// conversion went wrong, handle it
}
# fit the image into a bounding box of 500x500 pixels
Slika::run('input.jpg')->resize(500,500)->save('output.png', 'png');
# adjust the image to a maximum width of 500 pixels
Slika::run('input.jpg')->resize(500,0)->save('output.png', 'png');
# adjust the image to a maximum height of 500 pixels
Slika::run('input.jpg')->resize(0,500)->save('output.png', 'png');
use \splitbrain\slika\ImageInfo;
$info = new ImageInfo('input.jpg');
// on-disk state (stable regardless of chain operations)
$info->getRawWidth(); // e.g. 4000
$info->getRawHeight(); // e.g. 3000
$info->getExtension(); // 'jpeg'
$info->getOrientation(); // EXIF orientation 1..8
// the fluent chain simulates autorotate/rotate/resize/crop
// and returns the final tracked dimensions
list($w, $h) = (new ImageInfo('input.jpg'))
->autorotate()
->resize(500, 500)
->getDimensions();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.