Skip to content

Commit b527f77

Browse files
committed
Cleanup.
1 parent 4072776 commit b527f77

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
5353
### Fixed
5454
- Fixed compatibility with Intervention Image v3 crop operation using named parameters
5555
- Fixed `OperationsTest` to use proper mocking of `ImageInterface` instead of concrete class
56+
- Fixed `optimizeAndStore()` to explicitly encode image with file extension (resolves "No encoder found for empty file extension" error)
5657
- Updated all documentation examples to use correct Intervention Image v3 API
5758

5859
### Documentation

src/ImageProcessor.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,10 +297,13 @@ protected function optimizeAndStore(FileInterface $file, string $path): void
297297
$optimizerTempFile = TemporaryFile::create();
298298
$optimizerOutput = TemporaryFile::create();
299299

300-
// Save the image to the tmp file
301-
$this->image->save($optimizerTempFile, 90);
300+
// Encode the image with the proper format and write to temp file
301+
$encoded = $this->image->encodeByExtension($file->extension(), $this->quality);
302+
file_put_contents($optimizerTempFile, (string)$encoded);
303+
302304
// Optimize it and write it to another file
303305
$this->optimizer()->optimize($optimizerTempFile, $optimizerOutput);
306+
304307
// Open a new stream for the storage system
305308
$optimizerOutputHandler = openFile($optimizerOutput, 'rb+');
306309

0 commit comments

Comments
 (0)