* Set the path to the image that should be optimized. Public function canHandle(Image $image): bool * Determines if the given image can be handled by the optimizer. * Returns the name of the binary to be executed. An optimizer is any class that implements the Spatie\ImageOptimizer\Optimizers\Optimizer interface: namespace Spatie\ImageOptimizer\Optimizers Want to use another command-line utility to optimize your images? No problem. -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 to get the best compression.O3: this sets the optimization level to Gifsicle's maximum, which produces the slowest but best results Please be aware that SVGO can break your SVG.įor now, the default configuration used for SVGO is only compatible with SVGO 1.x To use options compatible with SVGO 2.x, you need to create your own optimization chain. SVGO's default configuration will be used, with the omission of the cleanupIDs plugin because that one is 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, progressively 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. -all-progressive: this will make sure the resulting image is a progressive one, meaning it can be downloaded using multiple passes of progressively higher details.-strip-all: this strips out all text information such as comments and EXIF data.This setting seems to satisfy Google's Pagespeed compression rules -m85: this will store the image with 85% quality.JPGs will be made smaller by running them through JpegOptim. The package will automatically decide which tools to use on a particular image. The package will use these optimizers if they are present on your system: 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. $optimizerChain = OptimizerChainFactory::create() This is the default way to use the package: use Spatie\ImageOptimizer\OptimizerChainFactory You can install the package via composer: composer require spatie/image-optimizer This package will automatically detect which optimization binaries are installed on your system and use them. Image-optimizer is a package released by Spatie that can optimize PNGs, JPGs, SVGs, and GIFs by running them through a chain of various image optimization tools. Image optimization is the process of creating and delivering high-quality images in the ideal format, size, and resolution to increase user engagement. Optimization of your images helps to ensure a better user experience and that meets users' expectations. Images are crucial to ensuring that your content is more accessible, attractive, and engaging to users, but they're equally important in terms of SEO.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |