Intervention / image

PHP Image Processing
https://image.intervention.io
MIT License
13.92k stars 1.5k forks source link

Improve Memory Usage #1269

Open olivervogel opened 9 months ago

olivervogel commented 9 months ago

Describe the feature you'd like General optimization of RAM consumption.

olivervogel commented 9 months ago

✅ Optimized in 3.3.2

Optimized Image Decoding - Previously file paths were read via file_get_contents() and are passed to the BinaryImageDecoder::class instead of handling the paths directly, which is more efficient

Old implementations

https://github.com/Intervention/image/blob/4462e6470446f7915a55ee7339c47681b30769de/src/Drivers/Gd/Decoders/FilePathImageDecoder.php#L31-L32

https://github.com/Intervention/image/blob/4462e6470446f7915a55ee7339c47681b30769de/src/Drivers/Imagick/Decoders/FilePathImageDecoder.php#L31-L32

This is now handled without reading to whole image via file_get_contents()

See https://github.com/Intervention/image/commit/d27fdd75e583dc0155548a86b4d93fe22b6af276, https://github.com/Intervention/image/commit/03a59283c3fc427c176dc411eb2a441a2d3c4488

olivervogel commented 9 months ago

✅ Optimized in 3.3.2

AbstractDecoder::extractExifData() now uses either file paths or binary data as direct input for exif_read_data(), instead of always creating a file pointer and reading from it as before.

Old Implementation

https://github.com/Intervention/image/blob/fd09f59b09b3f1ee9ad90a893230781f03d1e33d/src/Drivers/AbstractDecoder.php#L76-L91