Avoid response-copying when resizing images.

This commit is contained in:
Sergio Brighenti 2019-11-16 13:06:53 +01:00
parent 94219c4fa2
commit d7a78a0201
3 changed files with 22 additions and 8 deletions

View file

@ -379,7 +379,7 @@ class UploadController extends Controller
if (param($request, 'width') !== null && explode('/', $mime)[0] === 'image') {
$image = Image::make($storage->readStream($media->storage_path))
$response = Image::make($storage->readStream($media->storage_path))
->resize(
param($request, 'width'),
param($request, 'height'),
@ -388,12 +388,9 @@ class UploadController extends Controller
})
->resizeCanvas(param($request, 'width'),
param($request, 'height'), 'center')
->stream('png');
->psrResponse('png');
return $response
->withHeader('Content-Type', 'image/png')
->withHeader('Content-Disposition', $disposition.';filename="scaled-'.pathinfo($media->filename, PATHINFO_FILENAME).'.png"')
->withBody($image);
return $response->withHeader('Content-Disposition', $disposition.';filename="scaled-'.pathinfo($media->filename, PATHINFO_FILENAME).'.png"');
} else {
$stream = new Stream($storage->readStream($media->storage_path));

View file

@ -108,4 +108,6 @@ return [
'custom_head_html_hint' => 'This content will be added at the <head> tag on every page.',
'custom_head_set' => 'Custom Head HTML applied successfully.',
'remember_me' => 'Remember me',
'please_wait' => 'Please wait...',
'dont_close' => 'Do not close this tab until completion.',
];

View file

@ -78,7 +78,7 @@
</div>
</div>
</div>
<div class="col-md-6">
<div class="col-md-6 mt-3">
<div class="card shadow-sm same-height">
<div class="card-header"><i class="fas fa-language fa-fw"></i> {{ lang('enforce_language') }}</div>
<div class="card-body">
@ -125,7 +125,7 @@
<div class="col">
<form method="post" action="{{ route('system.upgrade') }}">
<button type="submit" id="doUpgradeButton" class="btn btn-block btn-outline-success" disabled><i class="fas fa-cloud-download-alt fa-fw"></i> {{ lang('upgrade') }}</button>
<button type="submit" id="doUpgradeButton" class="btn btn-block btn-outline-success" onsubmit="$('#modalLoading').modal({backdrop: 'static', keyboard: false})" disabled><i class="fas fa-cloud-download-alt fa-fw"></i> {{ lang('upgrade') }}</button>
</form>
</div>
</div>
@ -173,4 +173,19 @@
</div>
</div>
</div>
<div class="modal fade" id="modalLoading" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<h6 class="modal-title">{{ lang('please_wait') }}</h6>
</div>
<div class="modal-body text-center">
<i class="fas fa-10x fa-spinner fa-pulse"></i>
</div>
<div class="modal-footer">
{{ lang('dont_close') }}
</div>
</div>
</div>
</div>
{% endblock %}