diff --git a/src/Encoders/AvifEncoder.php b/src/Encoders/AvifEncoder.php index 62c9944..5ff60ce 100644 --- a/src/Encoders/AvifEncoder.php +++ b/src/Encoders/AvifEncoder.php @@ -42,13 +42,16 @@ public function encode(ImageInterface $image): EncodedImage /** * @throws StateException - * @return array{lossless: bool, Q: int, keep?: int, strip?: bool} + * @return array{lossless: bool, Q: int, effort: int, keep?: int, strip?: bool} */ private function options(): array { $options = [ 'lossless' => $this->quality === 100, 'Q' => $this->quality, + // libvips' heifsave defaults to effort=4; 1 encodes ~2-3x faster + // with near-identical bytes on typical web sources (range 0..9). + 'effort' => 1, ]; $strip = $this->strip || $this->driver()->config()->strip; diff --git a/src/Encoders/HeicEncoder.php b/src/Encoders/HeicEncoder.php index 1e1e382..d819881 100644 --- a/src/Encoders/HeicEncoder.php +++ b/src/Encoders/HeicEncoder.php @@ -42,13 +42,16 @@ public function encode(ImageInterface $image): EncodedImage /** * @throws StateException - * @return array{lossless: bool, Q: int, keep?: int, strip?: bool} + * @return array{lossless: bool, Q: int, effort: int, keep?: int, strip?: bool} */ private function options(): array { $options = [ 'lossless' => $this->quality === 100, 'Q' => $this->quality, + // libvips' heifsave defaults to effort=4; 1 encodes ~2-3x faster + // with near-identical bytes on typical web sources (range 0..9). + 'effort' => 1, ]; $strip = $this->strip || $this->driver()->config()->strip; diff --git a/src/Encoders/WebpEncoder.php b/src/Encoders/WebpEncoder.php index d9a0f4c..080547f 100644 --- a/src/Encoders/WebpEncoder.php +++ b/src/Encoders/WebpEncoder.php @@ -42,13 +42,17 @@ public function encode(ImageInterface $image): EncodedImage /** * @throws StateException - * @return array{lossless: bool, Q: int, keep?: int, strip?: bool} + * @return array{lossless: bool, Q: int, effort: int, keep?: int, strip?: bool} */ private function options(): array { $options = [ 'lossless' => $this->quality === 100, 'Q' => $this->quality, + // libvips' webpsave defaults to effort=4; 2 roughly halves encode + // time while staying within ~3% bytes (effort=1 costs +10-19%; + // range 0..6). + 'effort' => 2, ]; $strip = $this->strip || $this->driver()->config()->strip;