PHP code example of daaner / convertimage
1. Go to this page and download the library: Download daaner/convertimage 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/ */
daaner / convertimage example snippets
$serv = new ConvertImage;
$output = $serv->convert('/images/foobar.jpg?12345');
dd($output);
$serv = new ConvertImage;
$serv->setFolder('222');
$serv->convert('/images/foobar.jpg?12345');
// config - 'dir' => '/images',
// output /image/222/foobar.jpg
$serv = new ConvertImage;
$serv->deleteAfter(true);
$serv->convert('/images/foobar.jpg?12345');
// config - 'delete_after_convert' => false,
// output оригинал будет удален
$serv = new ConvertImage;
$serv->setName('foo baz bar 1');
$serv->convert('/images/foobar.jpg?12345');
// foo-baz-bar-1.jpg
$serv = new ConvertImage;
$serv->resize(600, 800);
$serv->convert('/images/foobar.jpg?12345');
// config - 'width' => 1200
// config - 'height' => 800
// output 'width' => 600
// output 'height' => 800
$serv = new ConvertImage;
$serv->setQuality(50);
$serv->convert('/images/foobar.jpg?12345');
// config - 'quality' => 80
// output 'quality' => 50
$serv = new ConvertImage;
$serv->createWebP(true);
$serv->convert('/images/foobar.jpg?12345');
// config - 'create_webp' => false
// output 'create_webp' => true
$serv = new ConvertImage;
$serv->setFormat('gif');
$serv->convert('/images/foobar.jpg?12345');
// config - 'format' => 'jpg'
// output file *.gif
$serv = new ConvertImage;
$serv->forceOverwrite(true);
$serv->convert('/images/foobar.jpg?12345');
// config - 'overwrite' => false
// output overwrite converted file if isset
$serv = new ConvertImage;
$serv->forceOverwrite(false);
$serv->setName('isset-foo-bar');
$serv->convert('/images/foobar.jpg?12345');
// config - 'overwrite' => false
// isset file isset-foo-bar.jpg
// output file isset-foo-bar-1234567.jpg
bash
php artisan vendor:publish --provider="Daaner\ConvertImage\ConvertImageServiceProvider"