|
12 | 12 | use chillerlan\Imagetiler\{Imagetiler, ImagetilerException, ImagetilerOptionsTrait};
|
13 | 13 | use chillerlan\Logger\{Log, LogOptionsTrait, Output\ConsoleLog};
|
14 | 14 | use chillerlan\Traits\ContainerAbstract;
|
| 15 | +use ImageOptimizer\OptimizerFactory; |
15 | 16 |
|
16 | 17 | require_once __DIR__.'/../vendor/autoload.php';
|
17 | 18 |
|
18 | 19 | $input = __DIR__.'/[YOUR HUGE IMAGE].png';
|
| 20 | +$utils = __DIR__.'/../../../utils/%s.exe'; |
19 | 21 |
|
20 | 22 | $options = [
|
21 | 23 | // ImagetilerOptions
|
|
28 | 30 | 'overwrite_base_image' => false,
|
29 | 31 | 'overwrite_tile_image' => true,
|
30 | 32 | 'clean_up' => false,
|
| 33 | + 'optimize_output' => true, |
| 34 | + 'memory_limit' => '2G', |
31 | 35 | // LogOptions
|
32 | 36 | 'minLogLevel' => 'debug',
|
33 | 37 | ];
|
34 | 38 |
|
| 39 | +$optimizer_settings = [ |
| 40 | + 'execute_only_first_png_optimizer' => false, |
| 41 | + 'advpng_bin' => sprintf($utils, 'advpng'), |
| 42 | + 'optipng_bin' => sprintf($utils, 'optipng'), |
| 43 | + 'pngcrush_bin' => sprintf($utils, 'pngcrush'), |
| 44 | + 'pngquant_bin' => sprintf($utils, 'pngquant'), |
| 45 | +]; |
| 46 | + |
35 | 47 | $options = new class($options) extends ContainerAbstract{
|
36 | 48 | use ImagetilerOptionsTrait, LogOptionsTrait;
|
37 | 49 | };
|
38 | 50 |
|
39 |
| -$logger = (new Log)->addInstance(new ConsoleLog($options), 'console'); |
40 |
| -$tiler = new Imagetiler($options, $logger); |
| 51 | +$logger = (new Log)->addInstance(new ConsoleLog($options), 'console'); |
| 52 | +$optimizer = (new OptimizerFactory($optimizer_settings, $logger))->get(); |
| 53 | +$tiler = new Imagetiler($options, $optimizer, $logger); |
41 | 54 |
|
42 | 55 | try{
|
43 | 56 | $tiler->process($input, __DIR__.'/tiles');
|
|
0 commit comments