#1485 Middle size images not preserve ratio

This commit is contained in:
fatihalp 2020-05-17 01:12:19 +03:00
parent 022b01398e
commit 3a11b5cf3f
2 changed files with 18 additions and 17 deletions

View File

@ -117,13 +117,13 @@ return [
'picture_width' => [ 'picture_width' => [
'type' => 'anomaly.field_type.integer', 'type' => 'anomaly.field_type.integer',
'config' => [ 'config' => [
'default_value' => 900, 'default_value' => 600,
], ],
], ],
'picture_height' => [ 'picture_height' => [
'type' => 'anomaly.field_type.integer', 'type' => 'anomaly.field_type.integer',
'config' => [ 'config' => [
'default_value' => 600, 'default_value' => 400,
], ],
], ],
'watermark_type' => [ 'watermark_type' => [

View File

@ -60,22 +60,23 @@ class UploadController extends AdminController
$watermarktype = $settings->value('visiosoft.module.advs::watermark_type'); $watermarktype = $settings->value('visiosoft.module.advs::watermark_type');
$position = $settings->value('visiosoft.module.advs::watermark_position'); $position = $settings->value('visiosoft.module.advs::watermark_position');
$fullImg = WaterMark::make($this->request->file('upload')->getRealPath()) $fullImg = WaterMark::make($this->request->file('upload')->getRealPath())
->resize( ->resize(null, setting_value('visiosoft.field_type.media::imageResizeH', 600),function ($constraint) {
setting_value('visiosoft.field_type.media::imageResizeW', null), $constraint->aspectRatio();
setting_value('visiosoft.field_type.media::imageResizeH', 600) })
) ->resizeCanvas(
->resizeCanvas( setting_value('visiosoft.field_type.media::imageCanvasW', 800),
setting_value('visiosoft.field_type.media::imageCanvasW', 800), setting_value('visiosoft.field_type.media::imageCanvasH', 600),
setting_value('visiosoft.field_type.media::imageCanvasH', 600), 'center', false, 'fff'
'center', );
false,
'fff'
);
$mdImg = WaterMark::make($this->request->file('upload')->getRealPath()) $mdImg = WaterMark::make($this->request->file('upload')->getRealPath())
->resize( ->resize(null, setting_value('visiosoft.module.advs::picture_height'),function ($constraint) {
setting_value('visiosoft.module.advs::picture_width'), $constraint->aspectRatio();
setting_value('visiosoft.module.advs::picture_height') })
); ->resizeCanvas(
setting_value('visiosoft.module.advs::picture_width', 400),
setting_value('visiosoft.module.advs::picture_height', 300),
'center', false, 'fff'
);
foreach ([$fullImg, $mdImg] as $index => $image) { foreach ([$fullImg, $mdImg] as $index => $image) {
if ($watermarktype == 'image') { if ($watermarktype == 'image') {
$watermarkimage_id = $settings->value('visiosoft.module.advs::watermark_image'); $watermarkimage_id = $settings->value('visiosoft.module.advs::watermark_image');