forked from bachors/PHP-Image-Compressor-Class
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.php
More file actions
25 lines (20 loc) · 650 Bytes
/
example.php
File metadata and controls
25 lines (20 loc) · 650 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?php
// include ImgCompressor.php
include_once('lib/ImgCompressor.class.php');
// setting
$setting = array(
'directory' => 'compressed', // directory file compressed output
'file_type' => array( // file format allowed
'image/jpeg',
'image/png',
'image/gif'
)
);
// create object
$ImgCompressor = new ImgCompressor($setting);
// run('STRING original file path', 'output file type', INTEGER Compression level: from 0 (no compression) to 9);
$result = $ImgCompressor->run('original/world.png', 'jpg', 5); // example level = 2 same quality 80%, level = 7 same quality 30% etc
// result array
echo '<pre>';
print_r($result);
echo '</pre>';