You can set the maximum of time in seconds that each individual optimizer in a chain can use by calling setTimeout: $optimizerChain In that example the package won't touch $pathToImage and write an optimized version to $pathToOutput. $optimizerChain-> optimize( $pathToImage, $pathToOutput) To keep the original image, you can pass through a second argument optimize: use Spatie\ ImageOptimizer\ OptimizerChainFactory The package will automatically detect which optimization binaries are installed on your system and use them. The image at $pathToImage will be overwritten by an optimized version which should be smaller. This is the default way to use the package: use Spatie\ ImageOptimizer\ OptimizerChainFactory (Settings are original taken from here) Usage -q 90 Quality factor that brings the least noticeable changes.-mt multithreading for some speed improvements.-pass 10 for maximizing the amount of analysis pass.-m 6 for the slowest compression method in order to get the best compression.-O3: this sets the optimization level to Gifsicle's maximum, which produces the slowest but best results.You'll find more info on that in this excellent blogpost by Sara Soueidan. Please be aware that SVGO can break your svg. SVGO's default configuration will be used, with the omission of the cleanupIDs and removeViewBox plugins because these are known to cause troubles when displaying multiple optimized SVGs on one page. -o2: this set the optimization level to two (multiple IDAT compression trials).-i0: this will result in a non-interlaced, progressive scanned image.After that we run the image through a second one: Optipng. We set no extra options, their defaults are used. The first one is Pngquant 2, a lossy PNG compressor. PNGs will be made smaller by running them through two tools.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |