PHP code example of artisansweb / image-optimizer
1. Go to this page and download the library: Download artisansweb/image-optimizer 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/ */
artisansweb / image-optimizer example snippets
use ArtisansWeb\Optimizer;
$img = new Optimizer();
$source = 'SOURCE_PATH_OF_IMAGE';
$img->optimize($source);
$source = 'SOURCE_PATH_OF_IMAGE';
$destination = 'DESTINATION_PATH_OF_IMAGE';
$img->optimize($source, $destination);
ArtisansWeb\Optimizer;
if (isset($_POST['submit'])) {
$img = new Optimizer();
move_uploaded_file($_FILES['file']['tmp_name'], 'images/'.$_FILES['file']['name']);
$img->optimize('images/'.$_FILES['file']['name']);
}