Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Memory Usage #1269

Open
olivervogel opened this issue Jan 15, 2024 · 2 comments
Open

Improve Memory Usage #1269

olivervogel opened this issue Jan 15, 2024 · 2 comments

Comments

@olivervogel
Copy link
Member

olivervogel commented Jan 15, 2024

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

@olivervogel
Copy link
Member Author

olivervogel commented Jan 28, 2024

✅ 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

// decode image
$image = parent::decode(file_get_contents($input));

// decode image
$image = parent::decode(file_get_contents($input));

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

See d27fdd7, 03a5928

@olivervogel
Copy link
Member Author

olivervogel commented Jan 28, 2024

✅ 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

protected function extractExifData(string $image_data): CollectionInterface
{
if (!function_exists('exif_read_data')) {
return new Collection();
}
try {
$pointer = $this->buildFilePointer($image_data);
$data = @exif_read_data($pointer, null, true);
fclose($pointer);
} catch (Exception) {
$data = [];
}
return new Collection(is_array($data) ? $data : []);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant