diff --git a/config/image-optimizer.php b/config/image-optimizer.php new file mode 100755 index 0000000..2024b21 --- /dev/null +++ b/config/image-optimizer.php @@ -0,0 +1,51 @@ + [ + + Jpegoptim::class => [ + '--strip-all', // this strips out all text information such as comments and EXIF data + '--all-progressive', // this will make sure the resulting image is a progressive one + '-m85' + ], + + Pngquant::class => [ + '--force' // required parameter for this package + ], + + Optipng::class => [ + '-i0', // this will result in a non-interlaced, progressive scanned image + '-o2', // this set the optimization level to two (multiple IDAT compression trials) + '-quiet' // required parameter for this package + ], + + Svgo::class => [ + '--disable=cleanupIDs' // disabling because it is know to cause troubles + ], + + Gifsicle::class => [ + '-b', // required parameter for this package + '-O3' // this produces the slowest but best results + ], + ], + + /** + * The maximum time in seconds each optimizer is allowed to run separately. + */ + 'timeout' => 60, + + /** + * If set to `true` all output of the optimizer binaries will be appended to the default log. + * You can also set this to a class that implements `Psr\Log\LoggerInterface`. + */ + 'log_optimizer_activity' => false, +]; \ No newline at end of file diff --git a/src/Model/Image.php b/src/Model/Image.php index 52e86f5..bc8f870 100755 --- a/src/Model/Image.php +++ b/src/Model/Image.php @@ -83,7 +83,7 @@ class Image extends Model if (empty($basePath)) { throw new \Exception('You must defined config image.path'); } - $parts = array_slice(str_split(mb_strtolower(str_slug($filename, '')), 2), 0, 2); + $parts = array_slice(str_split(md5($filename), 2), 0, 2); $path = $basePath . '/' . implode('/', $parts) . '/' . $filename; return $path; diff --git a/src/Providers/ImagesServiceProvider.php b/src/Providers/ImagesServiceProvider.php index 03e56b2..426a510 100755 --- a/src/Providers/ImagesServiceProvider.php +++ b/src/Providers/ImagesServiceProvider.php @@ -21,6 +21,7 @@ class ImagesServiceProvider extends ServiceProvider $this->loadMigrationsFrom(__DIR__ . '/../../database/migrations'); $this->mergeConfigFrom(__DIR__ . '/../../config/image.php', 'image'); + $this->mergeConfigFrom(__DIR__ . '/../../config/image-optimizer.php', 'image-optimizer'); $this->app->register(ImageServiceProvider::class);